我目前正在開發一個可以構建為 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
提交
取消