diff --git a/tools/goctl/api/gogen/util.go b/tools/goctl/api/gogen/util.go index 44d8a6fd..1306d1b8 100644 --- a/tools/goctl/api/gogen/util.go +++ b/tools/goctl/api/gogen/util.go @@ -28,6 +28,9 @@ func getParentPackage(dir string) (string, error) { var tempPath = absDir var hasGoMod = false for { + if tempPath == filepath.Dir(tempPath) { + break + } tempPath = filepath.Dir(tempPath) if goctlutil.FileExists(filepath.Join(tempPath, goModeIdentifier)) { tempPath = filepath.Dir(tempPath)