简体   繁体   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 . 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 . This is the import statement:这是导入语句:

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: 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

where <local_path> is where the (patched) git repo was saved.其中<local_path>是(已修补的)git 存储库的保存位置。 I added a go.mod file to this location ( <local_path>/lib/go/thrift ) simply containing this:我添加了一个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. However the Go compiler ( $ go build ) insists on downloading and using the Apache package and is ignoring the replace directive. Any ideas on the cause of this problem?关于这个问题的原因有什么想法吗?

The fix I found (after much experimenting) is to remove the go.mod file from <local_path>/lib/go/thrift (this step was essential ) and add this go.mod file to <local_path> :我发现的修复方法(经过大量试验)是从<local_path>/lib/go/thrift中删除go.mod文件(此步骤必不可少)并将此go.mod文件添加到<local_path>

module git.apache.org/thrift.git

go 1.12

Plus also change the replace directive to remove the lib/go/thrift part like this:另外还要更改replace指令以删除lib/go/thrift部分,如下所示:

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

The import statement was unchanged.进口声明没有改变。

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

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