[英]How to compare/diff specific version of master and fork repo in github
[英]How to replace a Go Module with a major version to a fork @ master
我在使用帶有/v2
/ 主要版本映射的項目的 go.mod 的任何固定分支映射分叉時遇到問題。
我有以下 go.mod:
go 1.18
require (
github.com/versent/saml2aws/v2 v2.35.0
)
注意該模塊需要/v2
,否則它會得到v2.17.0+incompatible
。
add-aad-entropy-PhoneAppNotification
: https://github.com/marcottedan/saml2aws/tree/add-aad-entropy-PhoneAppNotification
://github.com/marcottedan/saml2aws/tree/add-aad-entropy-PhoneAppNotificationmodule github.com/versent/saml2aws/v2
到module github.com/marcottedan/saml2aws/v2
我正在使用以下指令,但沒有一個有效:
這會下載我 fork 的標簽2.35.0
,即使我要求它獲取master
dmarcotte@dmarcottes% go get -d github.com/marcottedan/saml2aws/v2@master
go: downloading github.com/marcottedan/saml2aws/v2 v2.35.0
go: github.com/marcottedan/saml2aws/v2@v2.35.0: parsing go.mod:
module declares its path as: github.com/versent/saml2aws/v2
but was required as: github.com/marcottedan/saml2aws/v2
我還嘗試修改我的go.mod
:
replace github.com/versent/saml2aws/v2 => github.com/marcottedan/saml2aws/v2 v2.35.0
-> Can't find a way to target master with the /v2 pattern
如果我放棄 /v2 並使用 @master,它並不關心並獲取 v1 中的最新標簽(在 saml2aws 遷移到 go mod 之前,它被命名為 2.17.0+incompatible)
dmarcotte@dmarcottes % go get -d github.com/marcottedan/saml2aws@master
go: github.com/marcottedan/saml2aws@master: github.com/marcottedan/saml2aws@v1.8.5-0.20220520001825-f05a14a2b3f2: invalid version: go.mod has post-v1 module path "github.com/marcottedan/saml2aws/v2" at revision f05a14a2b3f2
我在這里很迷茫。
經過大量挖掘,以下是我發現似乎有效的步驟:
go.mod
第一行更改為您的新分叉名稱,提交和推送go get -d -u github.com/marcottedan/saml2aws/v2@master
其中@version 是您的分支名稱。go.mod
中,添加以下替換指令: replace github.com/versent/saml2aws/v2 v2.35.0 => github.com/marcottedan/saml2aws/v2 master
最后你的 go.mod 應該是這樣的:
module <yourname>
go 1.18
require (
github.com/versent/saml2aws/v2 v2.35.0
)
replace github.com/versent/saml2aws/v2 v2.35.0 => github.com/marcottedan/saml2aws/v2 master
請注意,如果您只是單獨工作,則可以使用 replace 指令映射驅動器上的本地文件夾。 但這往往不適用於隊友,因為他們在提取代碼時還必須檢查相同的確切分叉路徑。 這是一個例子:
module <yourname>
go 1.18
require (
github.com/versent/saml2aws/v2 v2.35.0
)
replace github.com/versent/saml2aws/v2 => /Users/dmarcotte/git/saml2aws/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.