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

Completes the addition of go module support, including vendored builds #1

Conversation

zgramana
Copy link

@zgramana zgramana commented Jan 16, 2019

Enables support for building projects using Go 1.11+ modules (
karalabe#138). This support assumes that you have either (a) cloned the root repository of the package you wish to build, or (b) that you are outside of GOPATH in a folder containing a go.mod file. See go help modules for details.

NOTE: Unless/until these changes are merged into @karalabe's repo, you will need to run docker build to create your own 1.11.x docker image and pass the image name to xgo as show in the example below.

Example usage:

xgo --targets=darwin/amd64,linux/amd64 -image zgramana-xgo .

Given the file ./go.mod where the first line is module foo_bar, the above command will output two binaries named foo_bar-darwin-10.6-amd64 and foo_bar-linux-amd64.

vendor Support

If you first run go mod vendor in your repository root and then run xgo, it will automatically detect /vendor and pass -mod=vendor to go build (the door is left open for supporting -mod=readonly).

Copy link
Owner

@kolaente kolaente left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this! I have a few improvements though.

docker/base/build.sh Show resolved Hide resolved
xgo.go Show resolved Hide resolved
xgo.go Show resolved Hide resolved
@kolaente kolaente merged commit 2b7ab94 into kolaente:feature/build-with-modules Jan 16, 2019
@kolaente
Copy link
Owner

Thanks!

@zgramana zgramana deleted the feature/build-with-modules branch January 16, 2019 21:41
@zgramana
Copy link
Author

\o/ Thanks for getting it started :)

crazy-max added a commit to crazy-max/xgo that referenced this pull request Feb 14, 2019
@zgramana zgramana restored the feature/build-with-modules branch March 5, 2019 00:28
@aboodman
Copy link

Sorry for maybe dumb question here, but I'm not very proficient with Docker. I cd'd into docker/go-1.11.x and ran docker build -t aa-xgo . and the resulting image did not include the changes to build.sh that enable modules support.

I realized that this was because the changes are on a branch, not master of this repo, so I switched to the branch and rebuilt, but the changes didn't get picked up.

I tried switching to docker/base and building that image, since that's where build.sh lives, but the build dies:

Step 22/50 : RUN   IOS_SDK_PATH=https://sdks.website/dl/iPhoneOS9.3.sdk.tbz2     &&   $FETCH $IOS_SDK_PATH db5ecf91617abf26d3db99e769bd655b943905e5 &&   mv `basename $IOS_SDK_PATH` iPhoneOS9.3.sdk.tar.bz2           &&   $UPDATE_IOS /iPhoneOS9.3.sdk.tar.bz2                          &&   rm -rf /iPhoneOS9.3.sdk.tar.bz2
 ---> Running in dbe0d09dcd6e
Downloading https://sdks.website/dl/iPhoneOS9.3.sdk.tbz2...
The command '/bin/sh -c IOS_SDK_PATH=https://sdks.website/dl/iPhoneOS9.3.sdk.tbz2     &&   $FETCH $IOS_SDK_PATH db5ecf91617abf26d3db99e769bd655b943905e5 &&   mv `basename $IOS_SDK_PATH` iPhoneOS9.3.sdk.tar.bz2           &&   $UPDATE_IOS /iPhoneOS9.3.sdk.tar.bz2                          &&   rm -rf /iPhoneOS9.3.sdk.tar.bz2' returned a non-zero code: 4

Am I on the right track here?

@kolaente
Copy link
Owner

kolaente commented May 15, 2019

It looks like https://sdks.website is not accessible and thus the build fails, hmmmm. I'm sorry, but I'm not that familiar with the internals of xgo either.

We actually forked xgo and added support for go modules (among other things) which works: https://github.com/techknowlogick/xgo. This one is also more up to date and activly maintained. We use it to build Gitea with go modules enabled. If you just want something "which works" I'd reccomend trying it.

@aboodman
Copy link

Thanks, I was hopeful there for a minute, but it doesn't seem to work for me because: techknowlogick/xgo#16

kolaente pushed a commit that referenced this pull request May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants