go install on the basis of the Go command

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
  1. [root@localhost ds]# ls
  2. showds.go
  3. [root@localhost ds]# go install
  4. [root@localhost ds]# ls
  5. showds.go
  6. [root@localhost ds]# ls $GOBIN
  7. ds
  8. [root@localhost ds]# cd ../../pkgtool/
  9. [root@localhost pkgtool]# go install
  10. go install: no install location for directory /root/goc2p/src/pkgtool outside GOPATH
  11. For more details see:'go help gopath'
  12. [root@localhost pkgtool]# export GOPATH=$GOPATH:~/goc2p
  13. [root@localhost pkgtool]# go install
  14. [root@localhost pkgtool]# ls
  15. envir.go envir_test.go fpath.go ipath.go pnode.go util.go util_test.go
  16. [root@localhost pkgtool]# cd ~/goc2p/
  17. [root@localhost goc2p]# cd pkg
  18. [root@localhost pkg]# ds
  19. /root/goc2p/pkg:
  20. linux_amd64/
  21. pkgtool.a

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326940104&siteId=291194637