亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

“go mod tidy”與“go build”的行為

“go mod tidy”與“go build”的行為

Go
ibeautiful 2023-07-17 13:53:25
假設我有一個具有以下結構的項目:+-- app/+-- otherstuff/+-- test/+-- go.mod+-- go.sum+-- main.go我可以通過運行以下命令來確保go.mod不包含未使用的依賴項go mod tidy:# 1) Verify that no dependency containing the name "modern-go" is found on go.mod$ grep 'modern-go' go.mod<-- Empty (nothing found) (OK)# 2) Run "go mod tidy", verify that nothing changes (i.e. go.mod is already clean)$ go mod tidy -vunused github.com/modern-go/concurrentunused github.com/modern-go/reflect2<-- messages above are displayed, but go.mod did not change# 3) Verify that go.mod did not change$ grep 'modern-go' go.mod<-- Empty (nothing found) (OK)現在,如果我運行go build,go.mod則會更新:# 4) Run "go build"$ go build# 5) go.mod was updated by "go build":$ grep 'modern-go' go.mod    github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect    github.com/modern-go/reflect2 v1.0.1 // indirect我不明白這是怎么回事。我預計go mod tidy會保持go.mod干凈的狀態,go build因此運行不會改變它。有任何想法嗎?
查看完整描述

1 回答

?
繁星coding

TA貢獻1797條經驗 獲得超4個贊

您所期望的行為通常是正確的。

Go 1.13 在這方面進行了一些修復。


查看完整回答
反對 回復 2023-07-17
  • 1 回答
  • 0 關注
  • 129 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號