
After installing go, we usually set the GOROOT and GOPATH environment variables. However, sometimes due to the complex project structure in actual work, when the set GOPATH cannot meet the needs, it can be set in cmd Temporary GOPATH;
Many IDEs, such as IDEA, can also set global GOPATH and temporary GOPATH, but compiling executable files may be complicated or the app.conf configuration file cannot be loaded when compiled or run through the IDE. situation, I have encountered this pitfall.
So the go executable file is generated through commands.

Since it depends on beego in github.com, we need to add github.com Parent directory to GOPATH.
set GOPATH=E :ProgrammerRouteGoDevelopment\
set GOOS=windows
set GOOS=linux
go install sayHello
in the src directory if no error is reported , the bin and pkg directories will be generated under GOPATH, and the executable file is in the bin directory, as shown in the figure:

Use versions after beego1.7.0 to run the go project with the IDE The configuration of app.conf cannot be loaded, nor can it be loaded using go install;
You can use go run main.go to load app.conf, and you can also use the bee tool to load it.
For more related knowledge, please pay attention to thego language tutorialcolumn
The above is the detailed content of Go language generates executable files through commands. For more information, please follow other related articles on the PHP Chinese website!
Usage of Type keyword in Go
How to implement linked list in go
What are the Go language programming software?
How to learn go language from 0 basics
What are the methods to implement operator overloading in Go language?
What are the operators in Go language?
Where should I fill in my place of birth: province, city or county?
What to do if php deserialization fails