Skip to content

Commit

Permalink
Adds the possibility to configure ldflags on builder (to use dlv with…
Browse files Browse the repository at this point in the history
… the generated binary)
  • Loading branch information
thgruiz committed Oct 20, 2022
1 parent c65df26 commit 47dd844
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (b Builder) Build(ctx context.Context, outputFile string) error {
// compile
cmd := buildEnv.newCommand("go", "build",
"-o", absOutputFile,
"-ldflags", "-w -s", // trim debug symbols
"-ldflags", b.osEnvOrDefaultValue("XK6_BUILD_LD_FLAGS", "-w -s"), // trim debug symbols by default
"-trimpath",
)
if b.RaceDetector {
Expand Down Expand Up @@ -257,3 +257,11 @@ const (

defaultK6ModulePath = "go.k6.io/k6"
)

func (b Builder) osEnvOrDefaultValue(name, defaultValue string) string {
s := os.Getenv(name)
if s == "" {
return defaultValue
}
return s
}

0 comments on commit 47dd844

Please sign in to comment.