在非Linux系统上运行Linux代码的go-guru

huangapple go评论83阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2017年6月23日 23:00:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/44724506.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定