From fe58b3627315c2cc0459b51ef0724f1193213351 Mon Sep 17 00:00:00 2001 From: bakito Date: Wed, 23 Sep 2020 14:32:17 +0200 Subject: [PATCH] correct handling windows backslash in import path --- ginkgo/generate_command.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ginkgo/generate_command.go b/ginkgo/generate_command.go index 4099f99a8..99557048a 100644 --- a/ginkgo/generate_command.go +++ b/ginkgo/generate_command.go @@ -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")