go get命令?
1、GO111MODULE这个名字可能是go的版本号有关系,module功能是在go1.1.1版本增加的。
2、GO111MODULE=off,go查询依赖包依赖GOPATH变量,工程fstest源码在$GOPATH/src下面,工程源码如下:
main.go:
package main
import (
"fmt"
"resty_chash"
)
func main() {
resty_chash.NewHashInstance()
fmt.Println("test search dir")
}
go编译main.go,查询依赖包的路径顺序如下:
/root/gowork/chash/src/fstest/vendor/resty_chash (vendor tree) //路径1
/usr/local/go/src/resty_chash (from $GOROOT) //路径2
/root/gowork/chash/src/resty_chash (from $GOPATH) //路径3
其中GOPATH=/root/gowork/chash,开发的时候必须在GOPATH下面创建目录src并在里面新建工程源码,如上。
路径1:在本工程的./vendor/resty_chash目录下搜索resty_chash
路径2:在$GOROOT/src/resty_chash目录下搜索resty_chash.go
路径3:在$GOPATH/src/resty_chash目录下搜索resty_chash.go
3、GO111MODULE=on,go命令会使用modules,而一点也不会去GOPATH目录下查找。