Skip to content

Conversation

techknowlogick
Copy link
Owner

patch from: #109 (comment)

@zeripath
Copy link
Collaborator

I wonder if the below would help?

diff --git a/xgo.go b/xgo.go
index 7934375..63d6ec9 100644
--- a/xgo.go
+++ b/xgo.go
@@ -261,6 +261,14 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
 		if _, err := os.Stat(config.Repository + "/go.mod"); err == nil {
 			usesModules = true
 		}
+		if !usesModules {
+			// Resolve the repository import path from the file path
+			config.Repository = resolveImportPath(config.Repository)
+
+			if _, err := os.Stat(config.Repository + "/go.mod"); err == nil {
+				usesModules = true
+			}
+		}
 
 		gopathEnv := os.Getenv("GOPATH")
 		if gopathEnv == "" && !usesModules {
@@ -273,9 +281,6 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
 			log.Fatalf("No $GOPATH is set or forwarded to xgo")
 		}
 		if !usesModules {
-			// Resolve the repository import path from the file path
-			config.Repository = resolveImportPath(config.Repository)
-
 			for _, gopath := range strings.Split(gopathEnv, string(os.PathListSeparator)) {
 				// Since docker sandboxes volumes, resolve any symlinks manually
 				sources := filepath.Join(gopath, "src")

@techknowlogick
Copy link
Owner Author

thanks @zeripath that was it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants