Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Using with go mod #138

Open
kolaente opened this issue Oct 27, 2018 · 9 comments · May be fixed by #144
Open

Using with go mod #138

kolaente opened this issue Oct 27, 2018 · 9 comments · May be fixed by #144

Comments

@kolaente
Copy link

Is it possible to use xgo with go modules? When using the latest version of xgo, it doesn't use the modules, I get an error like

go get: warning: modules disabled by GO111MODULE=auto in GOPATH/src;
	ignoring go.mod;
	see 'go help modules'

IMHO there are two possibilites to solve this: Either add an option to xgo which allows specifying extra evironment variables which are then passed to the container or an extra parameter to enable go modules (which would also pass an environment variable to the container).

@gordonklaus
Copy link

I don't think any extra options to xgo are needed. xgo can determine whether the package to be built is inside GOPATH or not and reproduce that setup in the container.

@kolaente
Copy link
Author

xgo can determine whether the package to be built is inside GOPATH or not and reproduce that setup in the container.

Is that currently working? So, if I mount it to somewhere outside of GOPATH, will xgo automatically use go modules? (Or is that a proposal) It could also look for a go.mod file and use go mod if it finds one.

@gordonklaus
Copy link

It's not currently working, it's a proposal.

@zaaksam
Copy link

zaaksam commented Dec 7, 2018

Need add Build flags "-mod=vendor"

@kolaente
Copy link
Author

kolaente commented Dec 7, 2018

@zaaksam Do you think it should also try to autodetect that and build accordingly? (aka look for a vendor folder and go.mod and the use the vendor folder) Or only use an extra flag to explicitly enable it?

@kolaente kolaente linked a pull request Dec 7, 2018 that will close this issue
@kolaente
Copy link
Author

kolaente commented Dec 7, 2018

I've hacked a pr together: #144

@zgramana
Copy link

The PR I sent to @kolaente (
kolaente#1) finishes the work he started. It autodetects the use of Go modules, and from there, uses go.mod to drive the rest of the build process. It also detects if a vendor directory is present, and if it is, passes -mod=vendor to go build. As a bonus, this also enables scenarios like #115 and #108.

@thewilli
Copy link

The PR I sent to @kolaente (
kolaente#1) finishes the work he started. It autodetects the use of Go modules, and from there, uses go.mod to drive the rest of the build process. It also detects if a vendor directory is present, and if it is, passes -mod=vendor to go build. As a bonus, this also enables scenarios like #115 and #108.

@zgramana so does this actually work now? (I was wondering because the PR seems to be merged while this issue is still open) 🤔

@zgramana
Copy link

This was merged into @kolaente’s fork. Given that they are actively maintaining theirs, I recommend you use theirs instead: https://github.com/techknowlogick/xgo.

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

Successfully merging a pull request may close this issue.

5 participants