i'm trying to dynamically compile go file for windows in linux host my code:
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
when i'm trying to compile:
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#
also in windows there is error:
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
help with any platform will be fine