Skip to content

Commit

Permalink
correct handling windows backslash in import path (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakito committed Sep 24, 2020
1 parent b5fe44d commit 97f3d51
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ginkgo/generate_command.go
Expand Up @@ -233,18 +233,20 @@ func getPackageImportPath() string {
panic(err.Error())
}

sep := string(filepath.Separator)

// Try go.mod file first
modRoot := findModuleRoot(workingDir)
if modRoot != "" {
modName := moduleName(modRoot)
if modName != "" {
cd := strings.Replace(workingDir, modRoot, "", -1)
cd = strings.ReplaceAll(cd, sep, "/")
return modName + cd
}
}

// Fallback to GOPATH structure
sep := string(filepath.Separator)
paths := strings.Split(workingDir, sep+"src"+sep)
if len(paths) == 1 {
fmt.Printf("\nCouldn't identify package import path.\n\n\tginkgo generate\n\nMust be run within a package directory under $GOPATH/src/...\nYou're going to have to change UNKNOWN_PACKAGE_PATH in the generated file...\n\n")
Expand Down

0 comments on commit 97f3d51

Please sign in to comment.