Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gomod fixes for go1.16 #121

Merged
merged 10 commits into from
Jul 23, 2021
Merged

gomod fixes for go1.16 #121

merged 10 commits into from
Jul 23, 2021

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.

None yet

2 participants