簡體   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