Y
Y
yordanmail2017-08-24 11:36:20
go
yordanmail, 2017-08-24 11:36:20

Golang how to compile application without debug information?

Good afternoon, I'm compiling the application using the following command:
go build -ldflags '-s -w' main_app.go
If a panic occurs during the program, I get a message, for example:
panic: runtime error: index out of range
goroutine 1 [running] :
main.main()
/emanuel/go/test_app/main_app.go:64 +0x324
exit status 2

Where is this information stored in the binary? Can it be removed from the binary?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Pavlyuk, 2017-08-24
@pav5000

If you need to remove the real paths to the files so that /emanuel/go is not lit, then this can be done using the GOROOT_FINAL environment variable
.
It is currently impossible to completely remove information about the stack trace from the binary, as far as I know.

I
IllusionTurtle, 2017-09-05
@IllusionTurtle

you can hide/replace absolute paths on errors, etc. -gcflags="-trimpath=$GOPATH/src"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question