mirror of
https://github.com/spf13/cobra.git
synced 2024-11-15 17:58:18 -07:00
cmd: Fix some gometalinter complaints
This commit is contained in:
parent
d9414968f8
commit
b5366273a6
@ -23,8 +23,6 @@ import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var projectPath string
|
||||
|
||||
var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"}
|
||||
var srcPaths []string
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user