From 20df76b65ea8e2521a50d5965443e1526d1a6700 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Wed, 13 Jan 2021 07:44:43 -0500 Subject: [PATCH] Make directory-not-empty error more self-explanatory 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. --- pkg/plugins/golang/v3/init.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/plugins/golang/v3/init.go b/pkg/plugins/golang/v3/init.go index b3308e0ba32..4dd41816a40 100644 --- a/pkg/plugins/golang/v3/init.go +++ b/pkg/plugins/golang/v3/init.go @@ -17,7 +17,6 @@ limitations under the License. package v3 import ( - "errors" "fmt" "os" "path/filepath" @@ -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 })