1 回答

TA貢獻1839條經驗 獲得超15個贊
使用-trimpath參數 to go build(not to gcflagsor asmflags):
沒有-trimpath:
$ go build .
$ ./panic
panic: bleh
goroutine 1 [running]:
main.example(0xc000046738, 0x2, 0x4, 0x473f2b, 0x5, 0xa)
/home/me/stuff/src/github.com/me/testing/panic/main.go:9 +0x39
main.main()
/home/me/stuff/src/github.com/me/testing/panic/main.go:4 +0x72
與-trimpath:
$ go build -trimpath .
$ ./panic
panic: bleh
goroutine 1 [running]:
main.example(0xc000046738, 0x2, 0x4, 0x473f2b, 0x5, 0xa)
github.com/me/testing/panic/main.go:9 +0x39
main.main()
github.com/me/testing/panic/main.go:4 +0x72
每go help build:
-trimpath
remove all file system paths from the resulting executable.
Instead of absolute file system paths, the recorded file names
will begin with either "go" (for the standard library),
or a module path@version (when using modules),
or a plain import path (when using GOPATH).
- 1 回答
- 0 關注
- 120 瀏覽
添加回答
舉報