我有一个问题,-trimpath 没有从堆栈跟踪的最后一行中删除 GOPATH。 下面是堆栈跟踪的快照:
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x144efd2]
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: goroutine 1 [running]:
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: github.com/go-redis/redis.(*cmdable).HGetAll(0xc002cc78b0, 0x0, 0x0, 0x0)
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: github.com/go-redis/redis.(*cmdable).HGetAll(0xc002cc78b0, 0x0, 0x0, 0x0)
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: github.com/go-redis/[email protected]+incompatible/commands.go:923 +0xd2
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: controller/systemhealth.someOtherFunc(...)
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: controller/systemhealth/system_health.go:676
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: controller/systemhealth.someFunction(...)
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: controller/systemhealth/system_health.go:680
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: controller/systemhealth.ServiceInitialize()
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: controller/systemhealth/system_health.go:685 +0x6b
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: main.main()
Apr 15 09:56:59 10-79-108-22 system-health[3923528]: /home/hemant/dev/go/src/controller/go-controller.go:743 +0x231e
我的 GOPATH =
/home/hemant/dev/go/src
构建时我的编译器标志是:
-gcflags=-trimpath=$GOPATH -trimpath -asmflags=-trimpath=$GOPATH -trimpath
GOPATH 也应该从最后一行中删除。
还有一个附带问题:是否可以不公开目录路径而仅包含文件名?
根据评论,仅设置
-trimpath
而没有 -gcflags=...
和 -asmflags=....
解决了问题(这可能是由于与 GOPATH 的混淆)。