{"id":208235,"date":"2025-07-08T13:49:47","date_gmt":"2025-07-08T05:49:47","guid":{"rendered":"https:\/\/server.hk\/cnblog\/208235\/"},"modified":"2025-07-08T13:49:47","modified_gmt":"2025-07-08T05:49:47","slug":"%e6%97%a0%e6%b3%95%e4%bb%8e%e7%a7%81%e6%9c%89github%e5%ad%98%e5%82%a8%e5%ba%93%e8%8e%b7%e5%8f%96go%e5%8c%85","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/208235\/","title":{"rendered":"\u65e0\u6cd5\u4ece\u79c1\u6709github\u5b58\u50a8\u5e93\u83b7\u53d6go\u5305"},"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>\u65e0\u6cd5\u4ece\u79c1\u6709github\u5b58\u50a8\u5e93\u83b7\u53d6go\u5305<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-30 16:12:39<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u77e5\u8bc6\u70b9\u638c\u63e1\u4e86\uff0c\u8fd8\u9700\u8981\u4e0d\u65ad\u7ec3\u4e60\u624d\u80fd\u719f\u7ec3\u8fd0\u7528\u3002\u4e0b\u9762\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2aGolang\u5f00\u53d1\u5b9e\u6218\uff0c\u624b\u628a\u624b\u6559\u5927\u5bb6\u5b66\u4e60\u300a\u65e0\u6cd5\u4ece\u79c1\u6709github\u5b58\u50a8\u5e93\u83b7\u53d6go\u5305\u300b\uff0c\u5728\u5b9e\u73b0\u529f\u80fd\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5e26\u5927\u5bb6\u91cd\u65b0\u6e29\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6e29\u6545\u800c\u77e5\u65b0\uff0c\u56de\u5934\u770b\u770b\u8bf4\u4e0d\u5b9a\u53c8\u6709\u4e0d\u4e00\u6837\u7684\u611f\u609f\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u5728\u6211\u5237\u65b0\u8ba1\u7b97\u673a\u4e4b\u524d\uff0c\u8fd9\u4e2a\u529f\u80fd\u53ef\u4ee5\u5b8c\u7f8e\u8fd0\u884c\uff0c\u73b0\u5728\u6211\u65e0\u6cd5\u4ece\u6211\u7684\u7ec4\u7ec7\u79c1\u6709 github \u5b58\u50a8\u5e93\u4e2d\u63d0\u53d6\u5305\u3002\u76ee\u524d\u6211\u53ea\u9700\u8981\u4e00\u4e2a ssh \u79c1\u94a5\u6765\u514b\u9686\u5b58\u50a8\u5e93\uff0c\u6211\u4e0d\u77e5\u9053\u4efb\u4f55 2fa \u8981\u6c42\u3002\u6211\u5df2\u7ecf\u82b1\u4e86\u51e0\u4e2a\u5c0f\u65f6\u8bd5\u56fe\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4ece\u6211\u8bfb\u5230\u7684\u5185\u5bb9\u6765\u770b\uff0c\u6211\u8ba4\u4e3a\u8fd9\u5e94\u8be5\u53ef\u884c\uff0c\u7701\u7565\u654f\u611f\u53d8\u91cf\u503c\u3002<\/p>\n<p>\u6211\u6536\u5230\u7684\u9519\u8bef\u662f\u672a\u77e5\u7248\u672c\uff0c\u4f46\u6211\u66f4\u6539\u4e86\u4e00\u4e9b\u5185\u5bb9\uff0c\u73b0\u5728\u6211\u6536\u5230\u201cssh\uff1a\u65e0\u6cd5\u89e3\u6790\u4e3b\u673a\u540d\u201d\u3002<\/p>\n<pre>#!\/bin\/bash\n    export GOPATH=\"$HOME\/go\"\n    export GOBIN=\"$HOME\/go\/bin\"\n    export GOPRIVATE=\"github.com\/${GITHUB_ORG}\"\n    \n    go env -w GO111MODULE=\"on\"\n    go env -w GOPRIVATE=\"github.com\/${GITHUB_ORG}\"\n    \n    git config --global url.\"[email&nbsp;protected]:\".insteadOf \"https:\/\/github.com\/\"\n    \n    pushd ~\/.ssh\n       eval $(ssh-agent);\n       ssh-add \"${GITHUB_PRIVATE_KEY_PATH}\"\n    popd\n    \n    go get package \"github.com\/${GITHUB_ORG}\/${GITHUB_REPO}\/${GO_PACKAGE}\"<\/pre>\n<p> <\/p>\n<h2>\u6b63\u786e\u7b54\u6848<\/h2>\n<p> <\/p>\n<p>\u60a8\u53d1\u5e03\u7684\u547d\u4ee4\u5728 git \u914d\u7f6e\u4e2d\u7f3a\u5c11 <code>url.ssh<\/code>\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u5c06 <code>git<\/code> \u66f4\u6539\u4e3a\u4f7f\u7528 ssh \u800c\u4e0d\u662f https\uff0c\u4ee5\u4fbf\u53ef\u4ee5\u4f7f\u7528 <code>go get<\/code> \u83b7\u53d6\u79c1\u6709 go \u5b58\u50a8\u5e93\u3002<\/p>\n<p>\u5efa\u8bae-<\/p>\n<pre>git config --global url.ssh:\/\/\/.insteadOf https:\/\/github.com\/<\/pre>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u65e0\u6cd5\u4ece\u79c1\u6709github\u5b58\u50a8\u5e93\u83b7\u53d6go\u5305\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\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-208235","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208235","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=208235"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208235\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=208235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=208235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=208235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}