Support dlv when debug enabled (#81)

* allow dlv when enable debug

* add comment

* merge two condition

* Update builder.go

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
This commit is contained in:
MisakaCloud 2022-02-17 04:26:25 +08:00 committed by GitHub
parent c8b2d00673
commit c7959560b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,7 +110,10 @@ func (b Builder) Build(ctx context.Context, outputFile string) error {
cmd := buildEnv.newCommand("go", "build",
"-o", absOutputFile,
)
if !b.Debug {
if b.Debug {
// support dlv
cmd.Args = append(cmd.Args, "-gcflags", "all=-N -l")
} else {
cmd.Args = append(cmd.Args,
"-ldflags", "-w -s", // trim debug symbols
"-trimpath",