在go mod 的require里面引入项目的last commit id
由于不知道哪个版本号,那么在require里面使用最近一次提交的commit id: 510aa62
go 1.3.3
require (
git.xx.cn/rd/dnsa 510aaa62
)
执行 go mod tidy
执行后就会发现已经帮我们自动引入了最后一次commit id对应的版本号
module git.arsyun.com/hos-device/go-lib-diskmanage
go 1.14
require (
git.arsyun.com/hos/go-lib-common v1.0.0
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/pkg/errors v0.9.1
github.com/shirou/gopsutil v2.20.8+incompatible
github.com/sirupsen/logrus v1.6.0
git.arsyun.com/hos/go-module-config fe11bdb9
)
go mod tidy
===>
module git.arsyun.com/hos-device/go-lib-diskmanage
go 1.14
require (
git.arsyun.com/hos/go-lib-common v1.0.0
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/pkg/errors v0.9.1
github.com/shirou/gopsutil v2.20.8+incompatible
github.com/sirupsen/logrus v1.6.0
git.arsyun.com/hos/go-module-config v1.0.1-0.20200925115257-fe11bdb98d9a
)
或者运行go get git.arsyun.com/hos/go-module-config@fe11bdb98d9a 也会生成
错误:
go: errors parsing go.mod:
/home/bill/go/src/hos-device/go-module-device-route/go.mod:5: unknown directive: require(
/home/bill/go/src/hos-device/go-module-device-route/go.mod:6: unknown directive: git.arsyun.com/hos/go-module-config
/home/bill/go/src/hos-device/go-module-device-route/go.mod:7: unknown directive: )
原因:好像是require(没有加空格导致的