The difference between go build and go install

Release: 2020-01-03 16:15:09
forward
2831 people have browsed it

Go (also known as Golang) is a statically strongly typed, compiled language developed by Google's Robert Griesemer, Rob Pike and Ken Thompson. This tutorial will introduce to you the difference between go build and go install ingo language.

The difference between go build and go install

go build

By go build plus the name of the Go source file to be compiled, we can get an executable file , by default the name of this file is the source file name minus the .go suffix.

$ go build hello.go $ lshello hello.go
Copy after login

Of course we can also specify other names through the -o option:

$ go build -o mygo hello.go $ lsmygo hello.go
Copy after login

If we directly execute the go build command in the go-examples directory without a file name, we will get An executable file with the same name as the directory name:

$ go build $ lsgo-examples hello.go
Copy after login

go install

Compared with the build command, the install command will also install the executable file or The library files are installed in the agreed directory.

The executable file compiled by go install is named after the directory name (DIR) where it is located.

go install installs the executable file into the bin directory at the same level as src. The bin directory is created by go install automatically creates

go install compiles the various packages that the executable file depends on and places them in the pkg directory at the same level as src

For more golang knowledge, please pay attention to the PHP Chinese websitegolang tutorialcolumn.

The above is the detailed content of The difference between go build and go install. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
go
source:csdn.net
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!