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

Support for projects using go modules in gexec.Build #340

Open
BooleanCat opened this issue Mar 13, 2019 · 2 comments
Open

Support for projects using go modules in gexec.Build #340

BooleanCat opened this issue Mar 13, 2019 · 2 comments
Assignees

Comments

@BooleanCat
Copy link
Contributor

Hey friends.

Looks like gexec.Build assumes a GOPATH - which is not necessarily true in this strange new world of go modules. I want to submit a PR to add support for building such projects however I'm a little stuck on the API.

What would you think of gexec.BuildMod(dir, path string, args ...string) (string, er) where path is just the path off the project being build (not relative to a GOPATH).

In order to build a binary using go modules I need to be:

  1. in the same dir as my go.mod
  2. GOPATHless

gexec.BuildMod("garden-runc-release/src/grootfs", "cmd/tardis", "-mod", "vendor") would do something analogous to:

$ cd garden-runc-release/src/grootfs
$ go build -mod vendor -o {some_temp_dir}/tardis cmd/tardis
@teddyking
Copy link

+1 for this feature! But as a quick/cheap workaround you can do something like:

pathToBinary, err := Build("../main.go")

@williammartin
Copy link
Collaborator

This would be super useful. I would definitely welcome a PR for this. Did you have any more thoughts on API?

@nodo nodo self-assigned this Jan 16, 2020
@blgm blgm assigned blgm and unassigned nodo Mar 4, 2020
tjvman added a commit to cloudfoundry/cc-uploader that referenced this issue Jul 21, 2021
Passing the code.cloudfoundry.org path doesn't work with go mod and
`gexec.Build`. This is a [known
limitation](onsi/gomega#340) with Gomega.

Co-authored-by: Tom Viehman <[email protected]>
Co-authored-by: Weyman Fung <[email protected]>
tjvman added a commit to cloudfoundry/tps that referenced this issue Jul 21, 2021
Locket cannot be built when go modules are enabled. As a temporary
solution while the locket maintainers update to use modules, the tests
now expect the locket binary to be built independently and made
available on the $PATH.

Also, passing the code.cloudfoundry.org path when building tps-watcher doesn't
work with go mod and `gexec.Build`. This is a [known
limitation](onsi/gomega#340) with Gomega.

Co-authored-by: Tom Viehman <[email protected]>
Co-authored-by: Weyman Fung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants