diff --git a/cobra/cmd/helpers.go b/cobra/cmd/helpers.go index e5324c5..a53ab2e 100644 --- a/cobra/cmd/helpers.go +++ b/cobra/cmd/helpers.go @@ -23,8 +23,6 @@ import ( "text/template" ) -var projectPath string - var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"} var srcPaths []string diff --git a/cobra/cmd/init_test.go b/cobra/cmd/init_test.go index f9c9c46..9a918b9 100644 --- a/cobra/cmd/init_test.go +++ b/cobra/cmd/init_test.go @@ -54,7 +54,9 @@ func TestGoldenInitCmd(t *testing.T) { if err != nil { return err } - ioutil.WriteFile(goldenPath, got, 0644) + if err := ioutil.WriteFile(goldenPath, got, 0644); err != nil { + t.Fatal("Error while updating file:", err) + } } return compareFiles(path, goldenPath) } diff --git a/cobra/cmd/project.go b/cobra/cmd/project.go index a3e6d91..29fe127 100644 --- a/cobra/cmd/project.go +++ b/cobra/cmd/project.go @@ -37,7 +37,7 @@ func NewProject(projectName string) *Project { } for _, srcPath := range srcPaths { goPath := filepath.Dir(srcPath) - if filepath.HasPrefix(wd, goPath) { + if strings.HasPrefix(wd, goPath) { p.absPath = filepath.Join(srcPath, projectName) break } diff --git a/cobra/cmd/project_test.go b/cobra/cmd/project_test.go index 2774094..0900b8c 100644 --- a/cobra/cmd/project_test.go +++ b/cobra/cmd/project_test.go @@ -1,7 +1,7 @@ package cmd import ( - "path/filepath" + "strings" "testing" ) @@ -17,7 +17,7 @@ func TestFindExistingPackage(t *testing.T) { func hasGoPathPrefix(path string) bool { for _, srcPath := range srcPaths { - if filepath.HasPrefix(path, srcPath) { + if strings.HasPrefix(path, srcPath) { return true } }