Reputation:
How can i run this Go code in my Android? (in Fedora 15 its working).
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
Upvotes: 11
Views: 5133
Reputation: 65
With Go 1.0, the compilers changed from separate compiler executables for different target architectures to a single compiler executable. Thus, the process of compiling for ARM is slightly different from Go 1.0 on:
CGO_ENABLED=0
GOOS=linux
GOARCH=arm
go build main.go
The (environment) variables GOOS and GOARCH have to be set to match the android environment, which is a linux OS and an ARM hardware architecture. Then you can use go build
as you would compile for any other platform (which will then act according to the set variables).
Upvotes: 3