繁体   English   中英

go.mod 替换指令被忽略

[英]go.mod replace directive is ignored

I'm using the Go thrift package from Apache, which is at lib/go/thrift in the Git repo at git.apache.org/thrift.git . 这是导入语句:

import "git.apache.org/thrift.git/lib/go/thrift"

This works fine for using the official Apache code but we needed to make a change to the Apache code so I just added a replace directive to the go.mod file for the project to pick up our changed version of the package:

replace git.apache.org/thrift.git/lib/go/thrift => <local_path>/lib/go/thrift

其中<local_path>是(已修补的)git 存储库的保存位置。 我添加了一个go.mod文件到这个位置( <local_path>/lib/go/thrift )只包含这个:

module git.apache.org/thrift.git/lib/go/thrift

go 1.12

However the Go compiler ( $ go build ) insists on downloading and using the Apache package and is ignoring the replace directive. 关于这个问题的原因有什么想法吗?

我发现的修复方法(经过大量试验)是从<local_path>/lib/go/thrift中删除go.mod文件(此步骤必不可少)并将此go.mod文件添加到<local_path>

module git.apache.org/thrift.git

go 1.12

另外还要更改replace指令以删除lib/go/thrift部分,如下所示:

replace git.apache.org/thrift.git => <local_path>

进口声明没有改变。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM