diff options
author | Martin Treusch von Buttlar <martin.tvb@vitraum.de> | 2017-05-20 13:17:48 +0200 |
---|---|---|
committer | Martin Treusch von Buttlar <martin.tvb@vitraum.de> | 2017-05-20 13:17:48 +0200 |
commit | 4c03187fbef64573ded62f40d5d4dace6c48747b (patch) | |
tree | 2a4991b142afc022f5cebb1e2e0c19c091943661 /cmd/ponzu/new.go | |
parent | 6de9e9030108af25bf3c9cace0acc987f39ef2fd (diff) |
refactor and add documentation for 'ponzu new'
Diffstat (limited to 'cmd/ponzu/new.go')
-rw-r--r-- | cmd/ponzu/new.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/ponzu/new.go b/cmd/ponzu/new.go index 94e4697..0a19da1 100644 --- a/cmd/ponzu/new.go +++ b/cmd/ponzu/new.go @@ -32,14 +32,15 @@ Errors will be reported, but successful commands return nothing.`, }, } -func checkNmkAbs(gPath string) (string, error) { +// name2path transforns a project name to an absolute path +func name2path(projectName string) (string, error) { gopath, err := getGOPATH() if err != nil { return "", err } gosrc := filepath.Join(gopath, "src") - path := gPath + path := projectName // support current directory if path == "." { path, err = os.Getwd() @@ -56,7 +57,7 @@ func checkNmkAbs(gPath string) (string, error) { return "", err } if len(srcrel) >= 2 && srcrel[:2] == ".." { - return "", fmt.Errorf("path '%s' must be inside '%s'", gPath, gosrc) + return "", fmt.Errorf("path '%s' must be inside '%s'", projectName, gosrc) } if srcrel == "." { return "", fmt.Errorf("path '%s' must not be %s", path, filepath.Join("GOPATH", "src")) @@ -76,7 +77,7 @@ func checkNmkAbs(gPath string) (string, error) { } func newProjectInDir(path string) error { - path, err := checkNmkAbs(path) + path, err := name2path(path) if err != nil && !os.IsNotExist(err) { return err } |