为了账号安全,请及时绑定邮箱和手机立即绑定

使用 go run 设置 GOOS

使用 go run 设置 GOOS

Cats萌萌 2022-01-04 21:12:12
我目前正在开发一个可以构建为 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尽管这样做是交叉编译的好方法


查看完整回答
反对 回复 2022-01-04
  • 1 回答
  • 0 关注
  • 561 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号