mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
cmd: Fix some gometalinter complaints
This commit is contained in:
parent
d9414968f8
commit
b5366273a6
4 changed files with 6 additions and 6 deletions
|
@ -23,8 +23,6 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
var projectPath string
|
|
||||||
|
|
||||||
var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"}
|
var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"}
|
||||||
var srcPaths []string
|
var srcPaths []string
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,9 @@ func TestGoldenInitCmd(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
return compareFiles(path, goldenPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func NewProject(projectName string) *Project {
|
||||||
}
|
}
|
||||||
for _, srcPath := range srcPaths {
|
for _, srcPath := range srcPaths {
|
||||||
goPath := filepath.Dir(srcPath)
|
goPath := filepath.Dir(srcPath)
|
||||||
if filepath.HasPrefix(wd, goPath) {
|
if strings.HasPrefix(wd, goPath) {
|
||||||
p.absPath = filepath.Join(srcPath, projectName)
|
p.absPath = filepath.Join(srcPath, projectName)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ func TestFindExistingPackage(t *testing.T) {
|
||||||
|
|
||||||
func hasGoPathPrefix(path string) bool {
|
func hasGoPathPrefix(path string) bool {
|
||||||
for _, srcPath := range srcPaths {
|
for _, srcPath := range srcPaths {
|
||||||
if filepath.HasPrefix(path, srcPath) {
|
if strings.HasPrefix(path, srcPath) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue