[Compile the Golang program under Windows into an executable binary file under Linux and execute it]


Compile the Golang program under Windows into an executable binary file under Linux and execute it


First, please confirm that golang has been installed,

And already configured GOROOT, GOPATH, GOBIN

In the folder where xx.go is located, press sheet + right mouse button to open it under dos, and execute the following command

set GOARCH=amd64

set GOOS=linux

go build xx.go

Will generate a xx binary file without suffix

Put the file into a folder in the linux system

grant permission

chmod 777 xx

B station is chmod -x xx

implement

./xx

The operation is successful. The binary file does not require any dependencies of go and can be run directly.

makefile writing
insert image description here

Reference:
https://blog.csdn.net/panshiqu/article/details/53788067

Guess you like

Origin blog.csdn.net/weixin_46356409/article/details/127059593
Recommended