{"id":208215,"date":"2025-07-08T09:51:02","date_gmt":"2025-07-08T01:51:02","guid":{"rendered":"https:\/\/server.hk\/cnblog\/208215\/"},"modified":"2025-07-08T09:51:02","modified_gmt":"2025-07-08T01:51:02","slug":"docker-%e5%ae%b9%e5%99%a8%e4%b8%8a%e7%9a%84go-get%e6%84%8f%e5%a4%96%e8%a1%8c%e4%b8%ba","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/208215\/","title":{"rendered":"docker \u5bb9\u5668\u4e0a\u7684\u201cgo get\u201d\u610f\u5916\u884c\u4e3a"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>docker \u5bb9\u5668\u4e0a\u7684\u201cgo get\u201d\u610f\u5916\u884c\u4e3a<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-30 13:51:36<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u719f\u6089\uff1f\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300adocker \u5bb9\u5668\u4e0a\u7684\u201cgo get\u201d\u610f\u5916\u884c\u4e3a\u300b<\/span>\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u5728\u770b\u5b8c\u672c\u7bc7\u6587\u7ae0\u540e\uff0c\u6709\u66f4\u597d\u7684\u5efa\u8bae\u6216\u8005\u53d1\u73b0\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u79ef\u6781\u8bc4\u8bba\u6307\u51fa\uff0c\u8c22\u8c22\uff01\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u52a0\u6cb9\u8fdb\u6b65\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u4e0e\u6211\u7684\u672c\u5730\u8ba1\u7b97\u673a\u76f8\u6bd4\uff0c\u5728 docker \u5bb9\u5668\u5185\u8fd0\u884c <code>go get [module]<\/code> \u65f6\uff0c\u6211\u9047\u5230\u4e86\u610f\u5916\u7684\u884c\u4e3a\uff0c\u5982\u679c\u60a8\u80fd\u5e2e\u52a9\u6211\u7406\u89e3\u8fd9\u79cd\u4e0d\u540c\u884c\u4e3a\u7684\u539f\u56e0\uff0c\u6211\u5c06\u4e0d\u80dc\u611f\u6fc0\u3002<\/p>\n<h1>1) \u672c\u5730\u673a\u5668<\/h1>\n<h2>\u547d\u4ee4\uff1a<\/h2>\n<pre>go get github.com\/axw\/gocov\/gocov<\/pre>\n<h2>\u7ed3\u679c\uff1a<\/h2>\n<ul>\n<li><em><strong>$gopath<\/strong>\/bin<\/em> \u5305\u542b\u53ef\u6267\u884c\u6587\u4ef6 <code>gocov<\/code>\u3002<\/li>\n<li>\u8be5\u6a21\u5757\u5df2\u4e0b\u8f7d\u5230 <em><strong>$gopath<\/strong>\/src\/github.com\/axw\/gocov\/gocov<\/em>\u3002<\/li>\n<li><em><strong>$gopath<\/strong>\/pkg<\/em> \u4e0d\u5305\u542b\u4e0e <code>gocov<\/code> \u5305\u76f8\u5173\u7684\u4efb\u4f55\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<h1>2) docker \u5bb9\u5668<\/h1>\n<h2>dockerfile\uff1a<\/h2>\n<p>\u6b64 dockerfile \u7528\u4e8e\u6d4b\u8bd5\u76ee\u7684\uff0c\u56e0\u4e3a\u5b83\u6ca1\u6709\u5165\u53e3\u70b9\u3002<\/p>\n<pre>FROM golang:alpine\n\nCOPY .  \/app\nWORKDIR \/app\n\nRUN go get -v -u github.com\/axw\/gocov\/gocov\nRUN ls $GOPATH\/bin\nRUN ls -laR \/ | grep \"^\\\/.*gocov.*$\"<\/pre>\n<h2>\u7ed3\u679c\uff1a<\/h2>\n<ul>\n<li><em><strong>$gopath<\/strong>\/bin<\/em> \u5305\u542b\u53ef\u6267\u884c\u6587\u4ef6 <code>gocov<\/code>\u3002<\/li>\n<li><em><strong>$gopath<\/strong>\/src<\/em> \u4e0d\u5305\u542b\u4e0e <code>gocov<\/code> \u5305\u76f8\u5173\u7684\u4efb\u4f55\u5185\u5bb9\u3002<\/li>\n<li>\u8be5\u6a21\u5757\u5df2\u4e0b\u8f7d\u5230 <em><strong>$gopath<\/strong>\/pkg\/mod\/github.com\/axw\/[email&nbsp;protected]<\/em>\u3002<\/li>\n<\/ul>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>\u4ece\u60a8\u53d1\u5e03\u672c\u6587\u4e4b\u65e5\u8d77\uff0c\u6211\u8ba4\u4e3a\u60a8\u6b63\u5728 docker \u5185\u8fd0\u884c go &gt;= 1.16.0\uff0c\u8fd9\u5bf9\u6a21\u5757\u7cfb\u7edf\u5f15\u5165\u4e86\u4e00\u4e9b\u66f4\u6539\uff08\u5982 @jimb \u8bc4\u8bba\uff1a<em>\u8bf7\u53c2\u9605 \u6709\u5173 go install \u548c go \u7684\u66f4\u6539\u5f97\u5230<\/em>\uff09\u3002\u60a8\u7684\u673a\u5668\u4e0a\u53ef\u80fd\u6b63\u5728\u8fd0\u884c\u65e7\u7248\u672c\u7684 go\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b <code>dockerfile<\/code> \u6765\u9a8c\u8bc1\u8fd9\u4e00\u70b9\uff1a<\/p>\n<pre>FROM golang:1.15\nCOPY .  \/app\nWORKDIR \/app\n\nRUN go get -v -u github.com\/axw\/gocov\/gocov\nRUN ls $GOPATH\/bin\nRUN ls -laR \/ | grep \"^\\\/.*gocov.*$\"<\/pre>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5305\u542b <code>$gopath\/src<\/code> \u5185\u4ee3\u7801\u7684\u56fe\u50cf\u3002<\/p>\n<p>\u672c\u7bc7\u5173\u4e8e\u300adocker \u5bb9\u5668\u4e0a\u7684\u201cgo get\u201d\u610f\u5916\u884c\u4e3a\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8eGolang\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-208215","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=208215"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208215\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=208215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=208215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=208215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}