Skip to content

Commit

Permalink
Fix not handling converting Windows file paths to Go package correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
joeriddles committed Sep 23, 2024
1 parent 6776267 commit 9593e2e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func NewGenerator(logger *log.Logger, cfg *config.Config) (Generator, error) {
}
pkg := filepath.Join(cfg.ModuleName, relPkg)
pkg = filepath.Dir(pkg) // remove filename
pkg = filepathToPackage(pkg)
typesPackage = &pkg
}

Expand All @@ -78,6 +79,9 @@ func NewGenerator(logger *log.Logger, cfg *config.Config) (Generator, error) {
repositoryPackage = filepath.Join(cfg.ModuleName, relPkg)
}

// Normalize filepath to Go package
repositoryPackage = filepathToPackage(repositoryPackage)

g := &generator{
logger: logger,
cfg: cfg,
Expand Down Expand Up @@ -931,3 +935,7 @@ func createDirs(paths ...string) error {
}
return nil
}

func filepathToPackage(path string) string {
return strings.ReplaceAll(path, "\\", "/")
}

0 comments on commit 9593e2e

Please sign in to comment.