1 回答

TA贡献1841条经验 获得超3个赞
您可以使用replace指令。
项目结构:
root
├── client
│ ├── go.mod
│ └── main.go
└── lib
├── go.mod
└── lib.go
go.modroot/lib模块:
module github.com/owner/root/lib
go 1.13
go.modroot/client模块:
module github.com/owner/root/client
go 1.13
require github.com/owner/root/lib v0.0.0
replace github.com/owner/root/lib => ../lib
这太可怕了,如果没有 VCS,你真的必须为每次导入都这样做吗?
不, replace指令替换模块的特定版本的内容,并包括属于替代模块的包。
root
├── client
│ ├── go.mod
│ └── main.go
└── lib
├── utils
│ └── util.go
├── libs
│ └── lib.go
└── go.mod
package main
import (
"github.com/owner/root/lib/utils"
"github.com/owner/root/lib/libs"
)
func main() {
//...
}
- 1 回答
- 0 关注
- 151 浏览
添加回答
举报