This commit is contained in:
anqiansong
2021-09-19 08:53:41 +08:00
committed by GitHub
parent 27249e021f
commit 7fb5bab26b
2 changed files with 32 additions and 1 deletions

View File

@@ -70,7 +70,20 @@ func getParentPackage(dir string) (string, error) {
return "", err
}
return filepath.ToSlash(filepath.Join(projectCtx.Path, strings.TrimPrefix(projectCtx.WorkDir, projectCtx.Dir))), nil
// fix https://github.com/zeromicro/go-zero/issues/1058
wd := projectCtx.WorkDir
d := projectCtx.Dir
same, err := ctlutil.SameFile(wd, d)
if err != nil {
return "", err
}
trim := strings.TrimPrefix(projectCtx.WorkDir, projectCtx.Dir)
if same {
trim = strings.TrimPrefix(strings.ToLower(projectCtx.WorkDir), strings.ToLower(projectCtx.Dir))
}
return filepath.ToSlash(filepath.Join(projectCtx.Path, trim)), nil
}
func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, indent int) error {