Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: imports path error on windows when generating code by priest su… #34

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tools/gone/priest/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"os"
"path"
"path/filepath"
"runtime"
"strings"
)

Expand Down Expand Up @@ -109,11 +110,18 @@
return ""
}

func normal(pkgPath string) string {
if runtime.GOOS == "windows" {
return strings.ReplaceAll(pkgPath, "\\", "/")

Check warning on line 115 in tools/gone/priest/loader.go

View check run for this annotation

Codecov / codecov/patch

tools/gone/priest/loader.go#L115

Added line #L115 was not covered by tests
}
return pkgPath
}

func (p *Pkg) genImportContent() string {
if path.Base(p.PkgPath) != p.Name {
return fmt.Sprintf(" %s \"%s\"", p.Name, p.PkgPath)
return fmt.Sprintf(" %s \"%s\"", p.Name, normal(p.PkgPath))
} else {
return fmt.Sprintf(" \"%s\"", p.PkgPath)
return fmt.Sprintf(" \"%s\"", normal(p.PkgPath))
}
}

Expand Down