From b5366273a6b41e93decceeaeef005516cab56c24 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Sun, 14 May 2017 12:27:15 +0200 Subject: [PATCH] cmd: Fix some gometalinter complaints --- cobra/cmd/helpers.go | 2 -- cobra/cmd/init_test.go | 4 +++- cobra/cmd/project.go | 2 +- cobra/cmd/project_test.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cobra/cmd/helpers.go b/cobra/cmd/helpers.go index e5324c53..a53ab2ef 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 f9c9c46c..9a918b9b 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 a3e6d91c..29fe127a 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 2774094c..0900b8cc 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 } }