add runner

This commit is contained in:
kim
2020-08-08 15:16:59 +08:00
committed by Kevin Wan
parent 760d3c8c4b
commit b1e8dd62da
8 changed files with 25 additions and 16 deletions

View File

@@ -4,13 +4,14 @@ import (
"fmt"
goformat "go/format"
"io"
"os"
"path"
"path/filepath"
"strings"
"zero/core/collection"
"zero/tools/goctl/api/spec"
"zero/tools/goctl/api/util"
"zero/tools/goctl/vars"
)
func getParentPackage(dir string) (string, error) {
@@ -18,12 +19,13 @@ func getParentPackage(dir string) (string, error) {
if err != nil {
return "", err
}
pos := strings.Index(absDir, vars.ProjectName)
gopath := os.Getenv("GOPATH")
parent := path.Join(gopath, "src")
pos := strings.Index(absDir, parent)
if pos < 0 {
return "", fmt.Errorf("%s not in project directory", dir)
return "", fmt.Errorf("%s not in GOPATH %s directory", absDir, gopath)
}
return absDir[pos:], nil
return absDir[len(parent)+1:], nil
}
func writeIndent(writer io.Writer, indent int) {