{"id":205940,"date":"2025-06-12T08:28:12","date_gmt":"2025-06-12T00:28:12","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205940\/"},"modified":"2025-06-12T08:28:12","modified_gmt":"2025-06-12T00:28:12","slug":"gopath-%e5%92%8c-go-module-%e4%b9%8b%e9%97%b4%e6%9c%89%e4%bb%80%e4%b9%88%e5%8c%ba%e5%88%ab%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205940\/","title":{"rendered":"GOPATH \u548c Go Module \u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b\uff1f"},"content":{"rendered":"<p>\u73cd\u60dc\u65f6\u95f4\uff0c\u52e4\u594b\u5b66\u4e60\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aGOPATH \u548c Go Module \u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u300b<\/span>\uff0c\u6b63\u6587\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u6216\u8005\u662f\u5bf9<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u6709\u7591\u95ee\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u6211\uff01\u540e\u9762\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u5185\u5bb9\u7684\uff0c\u5e0c\u671b\u90fd\u80fd\u5e2e\u5230\u6b63\u5728\u5b66\u4e60\u7684\u5927\u5bb6\uff01,<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241028\/1730110887671f65a708db6.jpg\" class=\"aligncenter\">,<br \/>\n<strong>Go Module \u4e0e GOPATH \u7684\u5f02\u540c<\/strong>,<br \/>\n<strong>\u80cc\u666f\u4ecb\u7ecd<\/strong>,\u5728 Go \u8bed\u8a00\u7684\u53d1\u5c55\u5386\u7a0b\u4e2d\uff0c\u4f9d\u8d56\u7ba1\u7406\u6a21\u5f0f\u7ecf\u5386\u4e86\u4e09\u4e2a\u9636\u6bb5\uff1aGOPATH\u3001vender \u548c Go Module\u3002\u5176\u4e2d\uff0cGOPATH \u662f Go \u8bed\u8a00\u4e2d\u7684\u4f20\u7edf\u6a21\u5f0f\uff0c\u5b58\u5728\u4e00\u4e9b\u4f9d\u8d56\u7248\u672c\u63a7\u5236\u65b9\u9762\u7684\u4e0d\u8db3\u4e4b\u5904\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0cGo \u5f15\u5165\u4e86 vender \u673a\u5236\uff0c\u5e76\u8fdb\u4e00\u6b65\u63a8\u51fa\u4e86 Go Module\uff0c\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u4f9d\u8d56\u7ba1\u7406\u89e3\u51b3\u65b9\u6848\u3002,<br \/>\n<strong>\u95ee\u9898\u89e3\u7b54<\/strong>,<br \/>\n<strong>1. \u8fc7\u53bb\u662f\u5426\u5fc5\u987b\u5728 GOPATH \u4e0b\u5f00\u53d1<\/strong>,\u662f\u7684\uff0c\u8fc7\u53bb\u5728 Go \u8bed\u8a00\u4e2d\u5f00\u53d1\u9879\u76ee\u5fc5\u987b\u4f4d\u4e8e GOPATH \u76ee\u5f55\u4e0b\u3002\u5426\u5219\uff0c\u7f16\u8bd1\u5668\u65e0\u6cd5\u627e\u5230\u6240\u9700\u7684\u4f9d\u8d56\u5e93\u3002,<br \/>\n<strong>2. \u5f53\u524d\u4e0d\u540c GO111MODULE \u8bbe\u7f6e\u4e0b\u7684\u5dee\u5f02<\/strong>,<br \/>\n<strong>3. Go Module \u76f8\u8f83 GOPATH \u7684\u6539\u8fdb<\/strong>,Go Module \u89e3\u51b3\u4e86 GOPATH \u6a21\u5f0f\u4e0b\u7684\u4ee5\u4e0b\u95ee\u9898\uff1a,<br \/>\n<strong>4. \u5f53\u524d\u4f9d\u8d56\u7ba1\u7406\u65b9\u5f0f<\/strong>,\u76ee\u524d\uff0cGo \u8bed\u8a00\u5f00\u53d1\u901a\u5e38\u4f7f\u7528 Go Module \u8fdb\u884c\u4f9d\u8d56\u7ba1\u7406\uff0c\u4e0d\u518d\u9700\u8981\u4f7f\u7528 vender \u673a\u5236\u3002Go Module \u5141\u8bb8\u5f00\u53d1\u8005\u5728\u4efb\u4f55\u4f4d\u7f6e\u521b\u5efa\u9879\u76ee\u5e76\u7ba1\u7406\u4f9d\u8d56\uff0c\u4ece\u800c\u63d0\u4f9b\u4e86\u66f4\u52a0\u7075\u6d3b\u548c\u4fbf\u6377\u7684\u5f00\u53d1\u4f53\u9a8c\u3002,\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8eGOLANG\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~,\u7b2c\u4e09\u65b9\u4f9d\u8d56\u7684\u66f4\u65b0\u53ef\u80fd\u4f1a\u8986\u76d6\u672c\u5730\u4fee\u6539\u3002,\u4f9d\u8d56\u641c\u7d22\u987a\u5e8f\u50f5\u5316\uff0c\u4e0d\u7075\u6d3b\u3002,\u65e0\u6cd5\u63a7\u5236\u4f9d\u8d56\u7684\u7248\u672c\u3002,<br \/>\n<strong>GO111MODULE=on\uff1a<\/strong>\u9879\u76ee\u5fc5\u987b\u4f4d\u4e8e GOPATH \u5916\u624d\u80fd\u4f7f\u7528 Go Module \u8fdb\u884c\u4f9d\u8d56\u7ba1\u7406\u3002,<br \/>\n<strong>GO111MODULE=off\uff1a<\/strong>\u9879\u76ee\u53ef\u4ee5\u4f4d\u4e8e GOPATH \u5185\u5916\uff0c\u5747\u53ef\u6b63\u5e38\u627e\u5230 GOPATH \u4e0b\u7684\u4f9d\u8d56\u3002,Go Module \u4e0e GOPATH \u7684\u5f02\u540c,\u73cd\u60dc\u65f6\u95f4\uff0c\u52e4\u594b\u5b66\u4e60\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aGOPATH \u548c Go Module \u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u300b<\/span>\uff0c\u6b63\u6587\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u6216\u8005\u662f\u5bf9<br \/>\n<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u6709\u7591\u95ee\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u6211\uff01\u540e\u9762\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u5185\u5bb9\u7684\uff0c\u5e0c\u671b\u90fd\u80fd\u5e2e\u5230\u6b63\u5728\u5b66\u4e60\u7684\u5927\u5bb6\uff01,<br \/>\n<b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>GOPATH \u548c Go Module \u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/span><\/p>\n<h1>GOPATH \u548c Go Module \u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/h1>\n<p><span>\u6765\u6e90\uff1aphp<\/span><br \/>\n<span>2024-10-28 18:21:42<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u73cd\u60dc\u65f6\u95f4\uff0c\u52e4\u594b\u5b66\u4e60\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aGOPATH \u548c Go Module \u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u300b<\/span>\uff0c\u6b63\u6587\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u6216\u8005\u662f\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u6709\u7591\u95ee\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u6211\uff01\u540e\u9762\u6211\u4f1a\u6301\u7eed\u66f4\u65b0\u76f8\u5173\u5185\u5bb9\u7684\uff0c\u5e0c\u671b\u90fd\u80fd\u5e2e\u5230\u6b63\u5728\u5b66\u4e60\u7684\u5927\u5bb6\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241028\/1730110887671f65a708db6.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>Go Module \u4e0e GOPATH \u7684\u5f02\u540c<\/strong><\/p>\n<p><strong>\u80cc\u666f\u4ecb\u7ecd<\/strong><\/p>\n<p>\u5728 Go \u8bed\u8a00\u7684\u53d1\u5c55\u5386\u7a0b\u4e2d\uff0c\u4f9d\u8d56\u7ba1\u7406\u6a21\u5f0f\u7ecf\u5386\u4e86\u4e09\u4e2a\u9636\u6bb5\uff1aGOPATH\u3001vender \u548c Go Module\u3002\u5176\u4e2d\uff0cGOPATH \u662f Go \u8bed\u8a00\u4e2d\u7684\u4f20\u7edf\u6a21\u5f0f\uff0c\u5b58\u5728\u4e00\u4e9b\u4f9d\u8d56\u7248\u672c\u63a7\u5236\u65b9\u9762\u7684\u4e0d\u8db3\u4e4b\u5904\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0cGo \u5f15\u5165\u4e86 vender \u673a\u5236\uff0c\u5e76\u8fdb\u4e00\u6b65\u63a8\u51fa\u4e86 Go Module\uff0c\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u4f9d\u8d56\u7ba1\u7406\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p><strong>\u95ee\u9898\u89e3\u7b54<\/strong><\/p>\n<p><strong>1. \u8fc7\u53bb\u662f\u5426\u5fc5\u987b\u5728 GOPATH \u4e0b\u5f00\u53d1<\/strong><\/p>\n<p>\u662f\u7684\uff0c\u8fc7\u53bb\u5728 Go \u8bed\u8a00\u4e2d\u5f00\u53d1\u9879\u76ee\u5fc5\u987b\u4f4d\u4e8e GOPATH \u76ee\u5f55\u4e0b\u3002\u5426\u5219\uff0c\u7f16\u8bd1\u5668\u65e0\u6cd5\u627e\u5230\u6240\u9700\u7684\u4f9d\u8d56\u5e93\u3002<\/p>\n<p><strong>2. \u5f53\u524d\u4e0d\u540c GO111MODULE \u8bbe\u7f6e\u4e0b\u7684\u5dee\u5f02<\/strong><\/p>\n<ul>\n<li><strong>GO111MODULE=off\uff1a<\/strong>\u9879\u76ee\u53ef\u4ee5\u4f4d\u4e8e GOPATH \u5185\u5916\uff0c\u5747\u53ef\u6b63\u5e38\u627e\u5230 GOPATH \u4e0b\u7684\u4f9d\u8d56\u3002<\/li>\n<li><strong>GO111MODULE=on\uff1a<\/strong>\u9879\u76ee\u5fc5\u987b\u4f4d\u4e8e GOPATH \u5916\u624d\u80fd\u4f7f\u7528 Go Module \u8fdb\u884c\u4f9d\u8d56\u7ba1\u7406\u3002<\/li>\n<\/ul>\n<p><strong>3. Go Module \u76f8\u8f83 GOPATH \u7684\u6539\u8fdb<\/strong><\/p>\n<p>Go Module \u89e3\u51b3\u4e86 GOPATH \u6a21\u5f0f\u4e0b\u7684\u4ee5\u4e0b\u95ee\u9898\uff1a<\/p>\n<ul>\n<li>\u65e0\u6cd5\u63a7\u5236\u4f9d\u8d56\u7684\u7248\u672c\u3002<\/li>\n<li>\u4f9d\u8d56\u641c\u7d22\u987a\u5e8f\u50f5\u5316\uff0c\u4e0d\u7075\u6d3b\u3002<\/li>\n<li>\u7b2c\u4e09\u65b9\u4f9d\u8d56\u7684\u66f4\u65b0\u53ef\u80fd\u4f1a\u8986\u76d6\u672c\u5730\u4fee\u6539\u3002<\/li>\n<\/ul>\n<p><strong>4. \u5f53\u524d\u4f9d\u8d56\u7ba1\u7406\u65b9\u5f0f<\/strong><\/p>\n<p>\u76ee\u524d\uff0cGo \u8bed\u8a00\u5f00\u53d1\u901a\u5e38\u4f7f\u7528 Go Module \u8fdb\u884c\u4f9d\u8d56\u7ba1\u7406\uff0c\u4e0d\u518d\u9700\u8981\u4f7f\u7528 vender \u673a\u5236\u3002Go Module \u5141\u8bb8\u5f00\u53d1\u8005\u5728\u4efb\u4f55\u4f4d\u7f6e\u521b\u5efa\u9879\u76ee\u5e76\u7ba1\u7406\u4f9d\u8d56\uff0c\u4ece\u800c\u63d0\u4f9b\u4e86\u66f4\u52a0\u7075\u6d3b\u548c\u4fbf\u6377\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8eGOLANG\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1aphp \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664  <\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u672c\u5730Navicat\u8fde\u63a5\u8fdc\u7a0bDocker MySQL\u5931\u8d25\uff0c\u600e\u4e48\u529e\uff1f\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u57fa\u4e8e\u72b6\u6001\u5982\u4f55\u5bf9\u8ba2\u5355\u8fdb\u884c\u6392\u5e8f\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u73cd\u60dc\u65f6\u95f4\uff0c\u52e4\u594b\u5b66\u4e60\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26&#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-205940","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205940","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=205940"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205940\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}