Skip to content

Commit

Permalink
Make directory-not-empty error more self-explanatory
Browse files Browse the repository at this point in the history
When I encountered the error, I had to go to the source to understand
the problem.  Made the message more user-focused.

Also skipped printing the allowlist, both to fit into lint line-length
limits and to avoid overwhelming the user.
  • Loading branch information
justinsb committed Jan 14, 2021
1 parent 26d7b42 commit 20df76b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/plugins/golang/v3/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v3

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -188,7 +187,9 @@ func checkDir() error {
return err
}
if info.Name() != "go.mod" && !strings.HasPrefix(info.Name(), ".") {
return errors.New("only the go.mod and files with the prefix \"(.)\" are allowed before the init")
return fmt.Errorf(
"target directory is not empty (only go.mod and files with the prefix \".\" are allowed); found existing file %q",
path)
}
return nil
})
Expand Down

0 comments on commit 20df76b

Please sign in to comment.