{"id":10006713,"date":"2022-10-21T19:01:25","date_gmt":"2022-10-21T11:01:25","guid":{"rendered":"https:\/\/ityet.com\/?p=10006713"},"modified":"2022-10-21T19:01:25","modified_gmt":"2022-10-21T11:01:25","slug":"%e8%ae%b0%e4%b8%80%e6%ac%a1-go-mod-vendor-%e6%8a%a5%e9%94%99%e6%8e%92%e6%9f%a5%e7%bb%8f%e8%bf%87","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006713","title":{"rendered":"\u8bb0\u4e00\u6b21 go mod vendor \u62a5\u9519\u6392\u67e5\u7ecf\u8fc7"},"content":{"rendered":"<h3>\u4e00. \u95ee\u9898\u75c7\u72b6<\/h3>\n<p>\u6211\u4eec\u4f7f\u7528 jenkins \u811a\u672c\u6267\u884c go build \uff0c\u7528\u6765\u6784\u5efa\u7ebf\u4e0a\u670d\u52a1\u5668\u4f7f\u7528\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u6784\u5efa\u8fc7\u7a0b\u4e2d\u6709\u8fd9\u6837\u4e00\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<p><code>go mod vendor<\/code><\/p>\n<p>\u8be5\u6b65\u9aa4\u5c06\u4ee5 go.mod \u6587\u4ef6\u4e2d\u5199\u660e\u7684\u5305\u548c\u7248\u672c\u4e3a\u51c6\u4e0b\u8f7d\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5e76\u4fdd\u5b58\u5230\u672c\u5730\u7684 vendor \u76ee\u5f55\u3002\u4e0b\u8f7d\u8fc7\u7a0b\u4e2d\u5c06\u6821\u9a8c go.sum \u4e2d\u7684 hash \u503c\u662f\u5426\u540c\u6587\u4ef6 hash \u4e00\u81f4\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u6267\u884c\u4e2d\uff0c\u9047\u5230\u8fd9\u6837\u7684\u9519\u8bef\uff1a<\/p>\n<p><code>internal error: failed to find embedded files of github.com\/marten-seemann\/qtls-go1-18: \/\/go:build comment without \/\/ +build comment<\/code><\/p>\n<h3>\u4e8c. \u6392\u67e5\u7ecf\u8fc7<\/h3>\n<ol>\n<li>\u901a\u8fc7 qtls-go1-18 \u7684\u4ed3\u5e93\u540d\u53ef\u4ee5\u89c2\u5bdf\u5230\u95ee\u9898\u53ef\u80fd\u8ddf go 1.18 \u7684\u7248\u672c\u6709\u5173\u3002<\/li>\n<li>\u6253\u5f00\u4f9d\u8d56\u7684 github \u4ed3\u5e93\u53ef\u89c1\u7b80\u4ecb\uff1a<br \/><code>Go standard library TLS 1.3 implementation, modified for QUIC. For Go 1.18.<\/code><br \/>\u800c\u6211\u4eec\u6784\u5efa\u7684\u73af\u5883 go env \u8f93\u51fa\u7684\u7248\u672c\u4e3a  1.16<\/li>\n<\/ol>\n<p>PS: go env<\/p>\n<ol start=\"3\">\n<li>\u5728 go 1.18 \u7684 <a href=\"https:\/\/link.segmentfault.com\/?enc=GgVsZz0b7cKyiCrYkJRU5A%3D%3D.3eLlc2UuKb0iDL44HMCt5qXAEqPWK5G29rLkZCM3zlX5R4P%2FMO79kvF5oESUqnbM\" rel=\"nofollow\">release notes<\/a> \u4e2d\u67e5\u627e\u76f8\u5173\u4fe1\u606f\uff1a<\/li>\n<\/ol>\n<blockquote>\n<p>\/\/go:build lines<br \/>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.<\/p>\n<p>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.<\/p>\n<p>For more information, see <a href=\"https:\/\/link.segmentfault.com\/?enc=3ymRM9NmzuiVyqWO0wyNFA%3D%3D.ZvBmlZ2iReTiipdLGYq1xlz50z2pTPWy4kEfQEPQnJJdBXPjutbOmdvFTSN125Jq\" rel=\"nofollow\">https:\/\/go.dev\/design\/draft-g&#8230;<\/a><\/p>\n<\/blockquote>\n<p>\u62a5\u9519\u7684\u610f\u601d\u662f <code>\/\/go:build<\/code> \uff081.18 \u7248\u672c\u652f\u6301\uff09 \u5fc5\u987b\u540c <code>\/\/ +build<\/code> \u4e00\u8d77\u51fa\u73b0\u3002\u81f3\u6b64\u786e\u8ba4\u95ee\u9898\u539f\u56e0\u3002<br \/>\u89e3\u51b3\u529e\u6cd5<\/p>\n<p>\u4e1a\u52a1\u4ee3\u7801\u5e76\u6ca1\u6709\u76f4\u63a5\u7528\u5230 qtls \u5305\uff0c\u4e14\u5e76\u6ca1\u6709\u76f4\u63a5\u4f9d\u8d56 qtls-go1-18 \u5bf9\u5e94\u7684 go \u7248\u672c\u3002\u6b64\u5e93\u4e3a\u975e\u76f4\u63a5\u4f9d\u8d56\u5f15\u5165\u7684\uff0c\u9700\u8981\u627e\u51fa\u662f\u90a3\u4e2a\u5305\u5f15\u5165\u4e86\u8fd9\u4e2a\u4f9d\u8d56\u3002<\/p>\n<p><code>go mod why github.com\/marten-seemann\/qtls-go1-18<\/code><\/p>\n<p>\u53ef\u4ee5\u67e5\u770b\u662f\u8c01\u5f15\u5165\u8be5\u4f9d\u8d56\u3002\u4ece\u8f93\u51fa\u53ef\u4ee5\u770b\u5230\uff1a<\/p>\n<pre><code># github.com\/marten-seemann\/qtls-go1-18\ngit.mycompany.com\/group\/projecta\ngit.mycompany.com\/group\/projectb\ngithub.com\/smallnest\/rpcx\/client\ngithub.com\/lucas-clemente\/quic-go\ngithub.com\/marten-seemann\/qtls-go1-18<\/code><\/pre>\n<p>\u901a\u8fc7 <code>go mod graph<\/code> \u53ef\u4ee5\u770b\u5230\u5177\u4f53\u90a3\u4e2a\u5305\u7684\u90a3\u4e2a\u7248\u672c\u5f15\u5165\u7684<\/p>\n<p>\u6700\u7ec8\u786e\u8ba4\u662f quic-go \u7684 0.27 \u5f15\u5165\u7684\u3002<\/p>\n<p>\u5728 go.mod \u4e2d\u6392\u9664\u6389 quic-go 0.27 \u5373\u53ef\u3002\u5728 go.mod \u4e2d\u52a0\u4e00\u884c\u3002<\/p>\n<pre><code>exclude lucas-clemente\/quic-go v0.27.0<\/code><\/pre>\n<h3>\u4e09. \u603b\u7ed3\u548c\u5176\u4ed6<\/h3>\n<ol>\n<li>\u4e3a\u4ec0\u4e48 go mod vendor \u4f1a\u66f4\u65b0\u7248\u672c\uff0c\u7406\u8bba\u4e0a\u53ea\u4f1a\u4f7f\u7528 go.mod \u4e2d\u6307\u5b9a\u7684\u7248\u672c\uff1b<\/li>\n<li>build \u673a\u5668\u4e0d\u9700\u8981 go mod vendor ,\u76f4\u63a5 go mod download \u5373\u53ef\uff1b<\/li>\n<li>go mod vendor \u540c go mod download \u5728\u4f9d\u8d56\u7ba1\u7406\u4e0a\u6709\u4ec0\u4e48\u4e0d\u540c\uff1f<\/li>\n<\/ol>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042660050\">https:\/\/segmentfault.com\/a\/1190000042660050<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00. \u95ee\u9898\u75c7\u72b6 \u6211\u4eec\u4f7f\u7528 jenkins \u811a\u672c\u6267\u884c go build \uff0c\u7528\u6765\u6784\u5efa\u7ebf\u4e0a\u670d\u52a1\u5668\u4f7f\u7528\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u6784 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006713","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006713"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006713\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}