an introduction
1. It is used to compile and install the code package or source code file.
2. The installation code package will generate an archive file under pkg/<platform-related directory> in the current workspace.
3. The source file of the installation command will generate an executable file in the bin directory or $GOBIN directory of the current workspace.
4. When the command is executed without any additional parameters, it will try to install the current directory as a code package.
5. When this command is executed with the import path of the code package as a parameter, the code package and its dependencies will be installed.
6. When the command is executed with the command source file and its library source file as parameters, only these files will be compiled and installed.
Two actual combat
[root@localhost ds]# ls
showds.go
[root@localhost ds]# go install
[root@localhost ds]# ls
showds.go
[root@localhost ds]# ls $GOBIN
ds
[root@localhost ds]# cd ../../pkgtool/
[root@localhost pkgtool]# go install
go install: no install location for directory /root/goc2p/src/pkgtool outside GOPATH
For more details see:'go help gopath'
[root@localhost pkgtool]# export GOPATH=$GOPATH:~/goc2p
[root@localhost pkgtool]# go install
[root@localhost pkgtool]# ls
envir.go envir_test.go fpath.go ipath.go pnode.go util.go util_test.go
[root@localhost pkgtool]# cd ~/goc2p/
[root@localhost goc2p]# cd pkg
[root@localhost pkg]# ds
/root/goc2p/pkg:
linux_amd64/
pkgtool.a