網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
問(wèn)題癥狀
我們使用 jenkins 腳本執(zhí)行 go build ,用來(lái)構(gòu)建線上服務(wù)器使用的二進(jìn)制文件。構(gòu)建過(guò)程中有這樣一個(gè)步驟:
go mod vendor
該步驟將以 go.mod 文件中寫(xiě)明的包和版本為準(zhǔn)下載第三方依賴并保存到本地的 vendor 目錄。下載過(guò)程中將校驗(yàn) go.sum 中的 hash 值是否同文件 hash 一致。
在實(shí)際執(zhí)行中,遇到這樣的錯(cuò)誤:
internal error: failed to find embedded files of github.com/marten-seemann/qtls-go1-18: //go:build comment without // +build comment
排查經(jīng)過(guò)
通過(guò) qtls-go1-18 的倉(cāng)庫(kù)名可以觀察到問(wèn)題可能跟 go 1.18 的版本有關(guān)。
打開(kāi)依賴的 github 倉(cāng)庫(kù)可見(jiàn)簡(jiǎn)介:
Go standard library TLS 1.3 implementation, modified for QUIC. For Go 1.18.
而我們構(gòu)建的環(huán)境 go env 輸出的版本為 1.16
在 go 1.18 的?release notes?中查找相關(guān)信息:
//go:build lines
Go 1.17 introduced //go:build lines as a more readable way to write build constraints, instead of // +build lines. As of Go 1.17, gofmt adds //go:build lines to match existing +build lines and keeps them in sync, while go vet diagnoses when they are out of sync.Since the release of Go 1.18 marks the end of support for Go 1.16, all supported versions of Go now understand //go:build lines. In Go 1.18, go fix now removes the now-obsolete // +build lines in modules declaring go 1.18 or later in their go.mod files.
報(bào)錯(cuò)的意思是?//go:build
?(1.18 版本支持) 必須同?// +build
?一起出現(xiàn)。至此確認(rèn)問(wèn)題原因。
解決辦法
業(yè)務(wù)代碼并沒(méi)有直接用到 qtls 包,且并沒(méi)有直接依賴 qtls-go1-18 對(duì)應(yīng)的 go 版本。此庫(kù)為非直接依賴引入的,需要找出是那個(gè)包引入了這個(gè)依賴。
go mod why github.com/marten-seemann/qtls-go1-18
可以查看是誰(shuí)引入該依賴。從輸出可以看到:
# github.com/marten-seemann/qtls-go1-18 git.mycompany.com/group/projecta git.mycompany.com/group/projectb github.com/smallnest/rpcx/client github.com/lucas-clemente/quic-go github.com/marten-seemann/qtls-go1-18
通過(guò)?go mod graph
?可以看到具體那個(gè)包的那個(gè)版本引入的
最終確認(rèn)是 quic-go 的 0.27 引入的。
在 go.mod 中排除掉 quic-go 0.27 即可。在 go.mod 中加一行。
exclude lucas-clemente/quic-go v0.27.0
總結(jié)和其他
- 為什么 go mod vendor 會(huì)更新版本,理論上只會(huì)使用 go.mod 中制定的版本;
- build 機(jī)器不需要 go mod vendor ,直接 go mod download 即可;
- go mod vendor 同 go mod download 在依賴管理上有什么不同?
原文鏈接:https://segmentfault.com/a/1190000042108758
相關(guān)推薦
- 2023-02-02 C語(yǔ)言中的冒泡排序問(wèn)題_C 語(yǔ)言
- 2022-11-10 pytorch人工智能之torch.gather算子用法示例_python
- 2023-07-07 Python Kmeans聚類(lèi)挑選合適的K值可視化
- 2022-01-19 解決element-ui 表格分頁(yè)序號(hào)不遞增問(wèn)題。
- 2022-06-20 基于C#實(shí)現(xiàn)語(yǔ)音識(shí)別功能詳解_C#教程
- 2022-08-03 Python的Web框架Django介紹與安裝方法_python
- 2022-12-06 .net程序開(kāi)發(fā)IOC控制反轉(zhuǎn)和DI依賴注入詳解_ASP.NET
- 2022-06-25 python格式化輸出實(shí)例(居中、靠右及靠左對(duì)齊)_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支