Skip to content

Commit 97f3d51

Browse files
authoredSep 24, 2020
correct handling windows backslash in import path (#721)
1 parent b5fe44d commit 97f3d51

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎ginkgo/generate_command.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,20 @@ func getPackageImportPath() string {
233233
panic(err.Error())
234234
}
235235

236+
sep := string(filepath.Separator)
237+
236238
// Try go.mod file first
237239
modRoot := findModuleRoot(workingDir)
238240
if modRoot != "" {
239241
modName := moduleName(modRoot)
240242
if modName != "" {
241243
cd := strings.Replace(workingDir, modRoot, "", -1)
244+
cd = strings.ReplaceAll(cd, sep, "/")
242245
return modName + cd
243246
}
244247
}
245248

246249
// Fallback to GOPATH structure
247-
sep := string(filepath.Separator)
248250
paths := strings.Split(workingDir, sep+"src"+sep)
249251
if len(paths) == 1 {
250252
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")

0 commit comments

Comments
 (0)
Please sign in to comment.