我正在尝试动态编译linux文件中的windows文件我的代码:
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
当我正在尝试编译时:
root@vm:/home/ubuntu/workspace# echo $GOROOT
/opt/go
root@vm:/home/ubuntu/workspace# echo $GOPATH
/home/ubuntu/workspace/
root@vm:/home/ubuntu/workspace# go build // works !
root@vm:/home/ubuntu/workspace# go build -compiler gccgo // works !
root@vm:/home/ubuntu/workspace# ls -sh workspace
28K workspace
root@vm:/home/ubuntu/workspace# GOOS=windows GOARCH=386 go build // works !
root@vm:/home/ubuntu/workspace# GOOS=windows GOARCH=386 go build -compiler gccgo
# _/home/ubuntu/workspace
./main.go:2:11: error: import file ‘fmt’ not found
import "fmt"
^
./main.go:4:2: error: reference to undefined name ‘fmt’
fmt.Println("Hello, 世界")
^
root@vm:/home/ubuntu/workspace#
在Windows中也有错误:
C:\Users\vm\Documents\aatest>go build -compiler gccgo
go build _/C_/Users/vm/Documents/aatest: : exec: "C:\\Users\\vm\\Documents\\aatest": file does not exist
C:\Users\vm\Documents\aatest>go build main.go -compiler gccgo
named files must be .go files
任何平台的帮助都会没问题