Home >Backend Development >Golang >How to run golang
There are two execution methods of Go language, one is to execute after compilation, and the other is to execute directly by go run.
1. Compile first and then execute It will compile an .exe executable file under Windows. If it is Linux or Mac, then there will be no suffix and it will still be an executable file) --->Execution output result 2. Directly execute go run
.go file (source code) on the source code ---> The underlying compilation and running is hidden (so the speed here is slightly slower than compilation) ---> Execution output resultThe difference between the two execution methods
①: If we compile and generate an executable file first, then we can copy the file to a computer without go development②: If we execute go run directly, then if we want to run on another machine, we also need a go development environment, otherwise it cannot be executed.
③: During compilation, the compiler will include the library files that the program depends on in the executable file, and the executable file will become larger.The above is the detailed content of How to run golang. For more information, please follow other related articles on the PHP Chinese website!