go module常见问题

1. 如何兼容GOPATH的旧项目,支持module

module 名取 github.com/****/projectName

go mod init github.com/fwhezfwhez/errorx
go mod tidy

2. golang.org/x 拉取不到怎么办

使用replace,在go.mod中增加:

replace (
	github.com/golangci/ineffassign => github.com/golangci/ineffassign v0.0.0-20180808204949-2ee8f2867dde
)

3. 迁移新版本,打上go module后,发现第三方依赖的版本不对,导致编译不过。

在旧项目的GOPATH/src里找到可用的第三方依赖,查看commit hash,修改require内容
go.mod

require (
    github.com/satori/go.uuid v0.0.0-20180103174451-36e9d2ebbde5
)

修改格式 v0.0.0-时间-commit-hash前12位

你可能感兴趣的:(go)