Skip to content

Commit

Permalink
Merge pull request #34 from gone-io/feature/1.x
Browse files Browse the repository at this point in the history
fix: imports path error on windows when generating code  by priest su…
  • Loading branch information
Degfy authored Aug 16, 2024
2 parents 1eecb3d + ef4780c commit b457340
Showing 1 changed file with 10 additions and 2 deletions.
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 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"
)

Expand Down Expand Up @@ -109,11 +110,18 @@ func (p *Pkg) generateFuncContent(isSelfModule bool) string {
return ""
}

func normal(pkgPath string) string {
if runtime.GOOS == "windows" {
return strings.ReplaceAll(pkgPath, "\\", "/")
}
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

0 comments on commit b457340

Please sign in to comment.