我有一个项目,其中包含 2 个不同的可执行文件,每个都有自己的依赖项以及对根目录的共享依赖项,如下所示:
Root
|->server
| |-> main.go
| |-> someOtherFiles.go
| |-> go.mod
| |-> go.sum
|->validator
| |-> main.go
| |-> someOtherFiles.go
| |-> go.mod
| |-> go.sum
|->utils
| |-> someOtherFiles.go
|->config
| |-> someOtherFiles.go
|-> go.mod
|-> go.sum
我的root的go.mod是这样的
module prex-kyc
go 1.13
require ({requiredDependencies})
我的验证器 go.mod 是这样的(服务器是模拟的)
module validator
go 1.13
require (
prex-kyc v0.0.0-00010101000000-000000000000
{otherRequiredDependencies}
)
replace prex-kyc => ../
在验证器和服务器的 main.go 中,我执行如下导入:
import (
"prex-kyc/utils"
{someOtherImports}
)
当我尝试构建其中一个项目时,我收到此错误:build validator: cannot load prex-kyc/config: malformed module path "prex-kyc/config": missing dot in first path element
我知道代码没有问题,因为它可以在其他人的环境中编译。
我尝试使用 go 版本 1.12 和 1.13 以及 Windows 10 和 Debian Linux 进行构建。