我目前正在开发一种可以构建为Windows服务或作为OSX / linux可执行文件运行的服务。
我在Windows文件上使用构建标记,包括使用main方法的文件
// +build windows
在另一个包含main方法的文件
上// +build !windows
当我在mac端执行go run *.go
时,出现以下错误
mainDOS.go:10:2: no buildable Go source files in /Users/michaelbrandenburg/Documents/git-repo/goCode/src/golang.org/x/sys/windows/svc
windowsService.go:15:2: no buildable Go source files in /Users/michaelbrandenburg/Documents/git-repo/goCode/src/golang.org/x/sys/windows/svc/debug
install.go:14:2: no buildable Go source files in /Users/michaelbrandenburg/Documents/git-repo/goCode/src/golang.org/x/sys/windows/svc/eventlog
install.go:15:2: no buildable Go source files in /Users/michaelbrandenburg/Documents/git-repo/goCode/src/golang.org/x/sys/windows/svc/mgr
有没有办法运行go run
并定位我想要运行的架构?我可以毫无问题地构建可执行文件。
答案 0 :(得分:1)
GOOS=darwin go run *.go
将为Mac OSX设置env。虽然像JimB说的那样,但没有太多意义。通过
GOOS=darwin go build *.go
是一种很好的交叉编译方式