Home>Article>Backend Development> How to run golang

How to run golang

(*-*)浩
(*-*)浩 Original
2019-12-31 09:53:38 4453browse

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 result2. 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 result

The 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!

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
Previous article:How to optimize golang Next article:How to optimize golang