英文:
go-guru on linux code in non-linux system
问题
我们使用Docker,因此源代码是针对Linux的。然而,我们在Mac上进行开发,因此在本地运行时go-guru-callers
无法正常工作。
它报错如下,但错误是因为该属性是特定于Linux的:
/Users/uri/Documents/connect/src/connect/job/native.go:104:4: struct字面量中的未知字段Pdeathsig
代码如下:
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
有什么解决方法吗?
英文:
We use docker and so the source code is for linux code. However, we develop on Macs, and as a result go-guru-callers
fails to work when run locally.
It complains with the error below but the error is because that property is linux specific:
/Users/uri/Documents/connect/src/connect/job/native.go:104:4: unknown field Pdeathsig in struct literal
and the code:
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
Any workarounds?
答案1
得分: 1
你可以使用构建条件来指定在哪个操作系统和架构上构建代码,以便将特定于平台的代码分离出来,避免这种编译失败。请参阅此处的go build文档。
英文:
You can use build conditions to specify what code should be built on what OS and architecture, in order to separate out code that is platform-specific and avoid these kinds of compilation failures. See the go build documentation here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论