{"id":207697,"date":"2025-07-08T12:40:47","date_gmt":"2025-07-08T04:40:47","guid":{"rendered":"https:\/\/server.hk\/cnblog\/207697\/"},"modified":"2025-07-08T12:40:47","modified_gmt":"2025-07-08T04:40:47","slug":"%e4%bd%bf%e7%94%a8%e8%bf%90%e8%a1%8c-%e8%bf%90%e8%a1%8c%e5%92%8c%e8%b0%83%e8%af%95-f5-ctrlf5-vs-%e4%bb%a3%e7%a0%81%e9%80%89%e9%a1%b9%e6%97%b6%ef%bc%8c%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae-visual-stu","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/207697\/","title":{"rendered":"\u4f7f\u7528\u8fd0\u884c\/\u8fd0\u884c\u548c\u8c03\u8bd5 (F5\/CTRL+F5) VS \u4ee3\u7801\u9009\u9879\u65f6\uff0c\u5982\u4f55\u914d\u7f6e Visual Studio Code \u6765\u8fd0\u884c\u5df2\u7f16\u8bd1\u7684 Go \u4ee3\u7801\uff1f"},"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>\u4f7f\u7528\u8fd0\u884c\/\u8fd0\u884c\u548c\u8c03\u8bd5 (F5\/CTRL+F5) VS \u4ee3\u7801\u9009\u9879\u65f6\uff0c\u5982\u4f55\u914d\u7f6e Visual Studio Code \u6765\u8fd0\u884c\u5df2\u7f16\u8bd1\u7684 Go \u4ee3\u7801\uff1f<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-24 19:03: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>\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\u5417\uff1f\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4f7f\u7528\u8fd0\u884c\/\u8fd0\u884c\u548c\u8c03\u8bd5 (F5\/CTRL+F5) VS \u4ee3\u7801\u9009\u9879\u65f6\uff0c\u5982\u4f55\u914d\u7f6e Visual Studio Code \u6765\u8fd0\u884c\u5df2\u7f16\u8bd1\u7684 Go \u4ee3\u7801\uff1f\u300b<\/span>\uff0c\u4e3b\u8981\u4ecb\u7ecd\u7684\u5185\u5bb9\u5c31\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u5982\u679c\u4f60\u60f3\u63d0\u5347\u81ea\u5df1\u7684\u5f00\u53d1\u80fd\u529b\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5927\u5bb6\u8981\u77e5\u9053\u7f16\u7a0b\u7406\u8bba\u57fa\u7840\u548c\u5b9e\u6218\u64cd\u4f5c\u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u54e6\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u5728\u8fd9\u7bc7\u535a\u6587\u4e4b\u540e\uff0c\u6211\u5b89\u88c5\u4e86\u4ee5\u4e0b\u4efb\u52a1\u6765\u7f16\u8bd1\u6211\u7684 go \u9879\u76ee\uff1ahttps:\/\/robertbasic.com\/blog\/build-and-run-golang-projects-in-vs-code\/<\/p>\n<p><strong>tasks.json<\/strong>\uff1a<\/p>\n<pre>{\n    \/\/ see https:\/\/go.microsoft.com\/fwlink\/?linkid=733558\n    \/\/ for the documentation about the tasks.json format\n    \"version\": \"2.0.0\",\n    \"tasks\": [\n        {\n            \"label\": \"build go\",\n            \"type\": \"shell\",\n            \"command\": \"go build\",\n            \"group\": {\n                \"kind\": \"build\",\n                \"isdefault\": true\n            }\n        }\n    ]\n}<\/pre>\n<p>\u73b0\u5728\u6211\u53ef\u4ee5\u4f7f\u7528 terminal&gt;run \u6784\u5efa\u4efb\u52a1\u6765\u7f16\u8bd1\u9879\u76ee<\/p>\n<p>\u4e3a\u4e86\u8fd0\u884c\u548c\u8c03\u8bd5\uff0c\u6211\u521b\u5efa\u4e86\uff1a<\/p>\n<p><strong>launch.json<\/strong>\uff1a<\/p>\n<pre>{\n    \/\/ use intellisense to learn about possible attributes.\n    \/\/ hover to view descriptions of existing attributes.\n    \/\/ for more information, visit: https:\/\/go.microsoft.com\/fwlink\/?linkid=830387\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n\n        {\n            \"name\": \"launch\",\n            \"type\": \"go\",\n            \"request\": \"launch\",\n            \"mode\": \"auto\",\n            \"program\": \"${filedirname}\",\n            \"cwd\": \"${workspaceroot}\",\n            \"args\": [],\n            \"env\": {}\n        }\n    ]\n}<\/pre>\n<p>\u4f46\u5b83\u4e0d\u8d77\u4f5c\u7528\uff0c\u6211\u6536\u5230\u4ee5\u4e0b\u6d88\u606f\uff1a<\/p>\n<pre>package .: no Go files in \/usr\/home\/username\/projects\/my_app\/.vscode\nProcess exiting with code: 1 signal: false<\/pre>\n<p>freebsd12.1 \u4e0b\u7684 visual studio code\uff08\u53ef\u80fd\u4e0d\u76f8\u5173\uff09\u3002<\/p>\n<p>\u4f7f\u7528 f5\/ctrl+f5 \u65f6\uff0c\u6211\u9700\u8981\u505a\u4ec0\u4e48\u624d\u80fd\u8ba9\u7a0b\u5e8f\u8fd0\u884c\uff1f \u6b22\u8fce\u4efb\u4f55\u63d0\u793a\uff0c\u5305\u62ec\u63a8\u8350\u7684\u5e2e\u52a9\u90e8\u5206\u6216\u535a\u5ba2\u6761\u76ee\u3002<\/p>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>\u5047\u8bbe\u6211\u7684\u4e3b\u5305\u4f4d\u4e8e\u5de5\u4f5c\u533a\u7684\u6839\u6587\u4ef6\u5939\u4e2d\uff0c\u6211\u603b\u662f\u5b9a\u4e49\u76f8\u540c\u7684 <code>.vscode\/launch.json<\/code>\uff1a<\/p>\n<pre>{\n    \/\/ Use IntelliSense to learn about possible attributes.\n    \/\/ Hover to view descriptions of existing attributes.\n    \/\/ For more information, visit: https:\/\/go.microsoft.com\/fwlink\/?linkid=830387\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n\n        {\n            \"name\": \"Launch\",\n            \"type\": \"go\",\n            \"request\": \"launch\",\n            \"mode\": \"auto\",\n            \"program\": \"${workspaceFolder}\",\n            \"env\": {},\n            \"args\": []\n        }\n    ]\n}\n<\/pre>\n<p>\u4ece\u90a3\u91cc\uff0c\u6211\u53ef\u4ee5\u4ece\u4efb\u4f55\u5730\u65b9\/\u4efb\u4f55\u6587\u4ef6\u6309 f5\uff0c\u8c03\u8bd5\u4f1a\u8bdd\u5c31\u4f1a\u5f00\u59cb\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\u6ce8\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/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-207697","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207697","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=207697"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207697\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=207697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=207697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=207697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}