Home  >  Article  >  Backend Development  >  What is the difference between run and build commands in go language?

What is the difference between run and build commands in go language?

青灯夜游
青灯夜游Original
2020-12-08 11:33:015567browse

Difference: The "go run" command can compile and run the program directly, but it will not generate an exe file, and the running speed is correspondingly slower; the "go build" command is used to test the compiled package, mainly checking whether there is Compilation errors will generate exe files, which run quickly.

What is the difference between run and build commands in go language?

The operating environment of this article: windows10 system, Go 1.11.2, thinkpad t480 computer.

Related recommendations: "Go Video Tutorial"

The difference between go run and go build commands

go run:

go run compiles and runs the program directly. It will generate a temporary file (but it does not actually exist and will not generate an .exe file). Directly Output the program execution results on the command line to facilitate user debugging. The running speed is also correspondingly slower

Note: you need to execute go run under the main package, otherwise as shown below

What is the difference between run and build commands in go language?

go build:

go build is used to test the compiled package, mainly checking whether there are compilation errors. If it is the source code of an executable file (that is, the main package), an executable file will be generated directly in the current directory ( .exe). Fast running speed

For more programming-related knowledge, please visit:Introduction to Programming! !

The above is the detailed content of What is the difference between run and build commands in go language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn