一 简介
1、用于编译并安装代码包或源码文件。
2、安装代码包会在当前工作区的pkg/<平台相关目录>下生成归档文件。
3、安装命令源码文件会在当前工作区的bin目录或$GOBIN目录下生成可执行文件。
4、执行该命令且不追加任何参数时,它会试图把当前目录作为代码包并安装。
5、执行该命令且以代码包的导入路径作为参数时,该代码包及其依赖会被安装。
6、执行该命令且以命令源码文件及其库源码文件作为参数时,只有这些文件会被编译并安装。
二 实战
[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