Skip to content

Commit

Permalink
Merge pull request #327 from torgiren/cgo_enabled_env
Browse files Browse the repository at this point in the history
improve: honor CGO_ENABLED env variable if it is set
  • Loading branch information
kakkoyun authored Feb 3, 2025
2 parents b51ceae + 0bf8c94 commit 64d5b5c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ func runBuild(binariesString string) {

ldflags = getLdflags(projInfo)

os.Setenv("CGO_ENABLED", "0")
if os.Getenv("CGO_ENABLED") == "" {
os.Setenv("CGO_ENABLED", "0")
defer os.Unsetenv("CGO_ENABLED")
}
if cgo {
os.Setenv("CGO_ENABLED", "1")
defer os.Unsetenv("CGO_ENABLED")
}
defer os.Unsetenv("CGO_ENABLED")

if binariesString == "all" {
buildAll(ext, prefix, ldflags, getTags(config.Build.Tags), binaries)
Expand Down

0 comments on commit 64d5b5c

Please sign in to comment.