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

Customizable GOFLAGS #6458

Closed
cova-fe opened this issue Dec 6, 2023 · 2 comments · Fixed by #6459
Closed

Customizable GOFLAGS #6458

cova-fe opened this issue Dec 6, 2023 · 2 comments · Fixed by #6459

Comments

@cova-fe
Copy link
Contributor

cova-fe commented Dec 6, 2023

What is the underlying problem you're trying to solve?

I'm putting together a gentoo ebuild and I'd like to use custom GOFLAGS
but the current Makefile seems to overwrite it.

My current solution:

I patched the Makefile in the following way, but I'm not sure it is the right approach:

diff -urN a/Makefile b/Makefile
--- a/Makefile  2023-11-30 16:17:55.000000000 +0100
+++ b/Makefile  2023-12-06 09:55:55.597276513 +0100
@@ -6,12 +6,13 @@

 CGO_ENABLED ?= 1
 WASM_ENABLED ?= 1
+GOFLAGS ?= "-buildmode=exe"

 # See https://golang.org/cmd/go/#hdr-Build_modes:
 # > -buildmode=exe
 # > Build the listed main packages and everything they import into
 # > executables. Packages not named main are ignored.
-GO := CGO_ENABLED=$(CGO_ENABLED) GOFLAGS="-buildmode=exe" go
+GO := CGO_ENABLED=$(CGO_ENABLED) GOFLAGS="$(GOFLAGS)" go
 GO_TEST_TIMEOUT := -timeout 30m

 GOVERSION ?= $(shell cat ./.go-version)

Additional Context

Any better solution?

@anderseknert
Copy link
Member

Looks reasonable to me. Please submit a PR, and we can continue the discussion there 😃

@cova-fe
Copy link
Contributor Author

cova-fe commented Dec 6, 2023

You have it :)

srenatus pushed a commit that referenced this issue Dec 8, 2023
In some cases it would be useful to specify custom GOFLAGS.
So, add the logic in Makefile and set the previous static value as default (-buildmode=exe)

closes #6458
Signed-off-by: Fabio Coatti <fabio.coatti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants