From 97f3d5137761e1cbf42023dd8ceda115ba6d2511 Mon Sep 17 00:00:00 2001 From: Marc Brugger Date: Thu, 24 Sep 2020 17:34:42 +0200 Subject: [PATCH] correct handling windows backslash in import path (#721) --- 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")