我目前正在开发一个可以构建为 Windows 服务或作为 OSX/linux 可执行文件运行的服务。我在 Windows 文件上使用构建标记,包括带有主要方法的标记// +build windows而在另一个包含主要方法的文件上// +build !windows当我go run *.go在mac端执行时,出现以下错误mainDOS.go:10:2: no buildable Go source files in /Users/michaelbrandenburg/Documents/git-repo/goCode/src/golang.org/x/sys/windows/svcwindowsService.go:15:2: no buildable Go source files in /Users/michaelbrandenburg/Documents/git-repo/goCode/src/golang.org/x/sys/windows/svc/debuginstall.go:14:2: no buildable Go source files in /Users/michaelbrandenburg/Documents/git-repo/goCode/src/golang.org/x/sys/windows/svc/eventloginstall.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和定位我想要运行的架构?我可以毫无问题地构建可执行文件。
1 回答

万千封印
TA贡献1891条经验 获得超3个赞
GOOS=darwin go run *.go
将为 Mac OSX 设置 env。不过,就像 JimB 所说的那样,没有多大意义。GOOS=darwin go build *.go
尽管这样做是交叉编译的好方法
添加回答
举报
0/150
提交
取消