{"id":22652,"date":"2023-07-13T12:19:13","date_gmt":"2023-07-13T04:19:13","guid":{"rendered":"https:\/\/www.yimenapp.com\/kb-yimen\/?p=22652"},"modified":"2023-07-13T12:19:13","modified_gmt":"2023-07-13T04:19:13","slug":"golang%e5%88%b6%e4%bd%9cexe%e6%8a%80%e6%9c%af%e5%8e%9f%e7%90%86%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.yimenapp.com\/kb-yimen\/22652\/","title":{"rendered":"golang\u5236\u4f5cexe\u6280\u672f\u539f\u7406\u4ecb\u7ecd"},"content":{"rendered":"<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/17\/14\/25192485619.jpg\" \/><\/figure><\/p>\n<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Golang\uff08Go\u8bed\u8a00\uff09\u521b\u5efa\u4e00\u6b3e\u7b80\u5355\u7684<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e5%8f%af%e6%89%a7%e8%a1%8c%e6%96%87%e4%bb%b6\/\" title=\"\u53ef\u6267\u884c\u6587\u4ef6\" target=\"_blank\">\u53ef\u6267\u884c\u6587\u4ef6<\/a><\/span>\uff08EXE\uff09\u3002Go\u662f\u4e00\u79cd\u7f16\u8bd1\u578b\u7f16\u7a0b\u8bed\u8a00\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u53ef\u4ee5\u5c06\u6e90\u4ee3\u7801\u76f4\u63a5\u7f16\u8bd1\u4e3a\u673a\u5668\u7ea7\u522b\u7684\u4ee3\u7801\uff0c\u800c\u65e0\u9700\u5176\u4ed6\u8bed\u8a00\u7684\u89e3\u91ca\u5668\u3002\u7f16\u8bd1\u4e3aEXE<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e6%96%87%e4%bb%b6\/\" title=\"\u6587\u4ef6\" target=\"_blank\">\u6587\u4ef6<\/a><\/span>\u53ef\u4ee5\u4f7f\u7a0b\u5e8f\u5728\u6ca1\u6709\u5b89\u88c5Go\u8fd0\u884c\u73af\u5883\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\uff0c\u5e76\u4e14\uff0c\u5b83\u7684\u8de8\u5e73\u53f0\u7279\u6027\u4f7f\u6211\u4eec\u80fd\u591f\u8f7b\u677e\u5730\u4e3a\u4e0d\u540c\u7684\u64cd\u4f5c<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e7%b3%bb%e7%bb%9f\/\" title=\"\u7cfb\u7edf\" target=\"_blank\">\u7cfb\u7edf<\/a><\/span>\u5236\u4f5c\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u5148\u4ecb\u7ecd\u4e00\u4e0bGolang\u5236\u4f5cEXE\u6587\u4ef6\u7684\u57fa\u672c\u539f\u7406\u548c\u6b65\u9aa4\u3002<\/p>\n<p>1. \u539f\u7406\uff1aGo\u7f16\u8bd1\u5668\u53ef\u4ee5\u5c06Go\u6e90\u4ee3\u7801\u76f4\u63a5\u7f16\u8bd1\u4e3a\u4e0d\u540c\u5e73\u53f0\u4e0b\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\uff0cGo\u5185\u7f6e\u4e86\u4e00\u4e2a\u7b80\u5355\u9ad8\u6548\u7684\u94fe\u63a5\u5668\uff0c\u7528\u4e8e\u5c06\u6240\u6709\u4f9d\u8d56\u5e93\u6253\u5305\u6210\u5355\u4e2a\u6587\u4ef6\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u76ee\u6807\u7cfb\u7edf\u4e0a\u76f4\u63a5\u8fd0\u884c\uff0c\u65e0\u9700\u5b89\u88c5Go\u8fd0\u884c\u73af\u5883\u3002<\/p>\n<p>2. \u4f7f\u7528Go\u7f16\u5199\u7b80\u5355\u7684\u7a0b\u5e8f\uff1a\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684Go\u7a0b\u5e8f\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u7f16\u5199\u4e00\u4e2a\u6253\u5370\u201cHello, World\uff01\u201d\u7684\u7a0b\u5e8f\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a`main.<a href=\"https:\/\/exe.yimenapp.com\/tool-2863.html\">vpk\u6253\u5305\u5de5\u5177<\/a>go` \u7684\u6587\u4ef6\uff0c\u5e76\u7c98\u8d34\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`go<\/p>\n<p>package main<\/p>\n<p>import &#8220;fmt&#8221;<\/p>\n<p>func main() {<\/p>\n<p>    fmt.Println(&#8220;Hello, World!&#8221;)<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>3. \u4e3aWindows\u7cfb\u7edf\u521b\u5efaEXE\u6587\u4ef6\uff1a\u5728\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u597dGo\u73af\u5883\u4e4b\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\u5e76\u5bfc\u822a\u5230`main.go`\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528`GOOS` \u548c`GOARCH` \u73af\u5883\u53d8\u91cf\u6765\u8de8\u5e73\u53f0\u7f16\u8bd1\u4ee3\u7801\u3002\u4e3a64\u4f4dWindows\u7cfb\u7edf\u521b\u5efaEXE\u6587\u4ef6\uff0c\u53ef\u4ee5\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`shell<\/p>\n<p>set GOOS=windows<\/p>\n<p>set GOARCH=amd64<\/p>\n<p>go build -o <span class=\"wpcom_keyword_link\"><a href=\"https:\/\/www.yimenapp.com\" target=\"_blank\" title=\"\u5f00\u53d1app\u4ece\u4e00\u95e8\u5f00\u59cb\">app<\/a><\/span>.<span class=\"wpcom_keyword_link\"><a href=\"https:\/\/exe.yimenapp.com\" title=\"exe\u5f00\u53d1\u4ece\u4e00\u95e8\u5f00\u59cb\">exe<\/a><\/span> main.go<\/p>\n<p>&#8220;`<\/p>\n<p>\u6b64\u65f6\uff0c\u4f60\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u770b\u5230\u4e00\u4e2a\u540d\u4e3a`app.exe`\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5c06\u8fd9\u4e2a\u6587\u4ef6\u590d\u5236\u5230\u4efb\u4f55Windows 64\u4f4d\u7cfb\u7edf\u4e0a\uff0c\u53cc\u51fb\u5373\u53ef\u8fd0\u884c\u3002<\/p>\n<p>4. \u4e3a\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\uff1aGolang\u652f\u6301\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf\u3002\u4e0e\u4e0a\u8ff0\u8fc7\u7a0b\u7c7b\u4f3c\uff0c\u6211\u4eec\u53ef\u4ee5\u4fee\u6539`GOOS` \u548c`GOARCH` \u73af\u5883\u53d8\u91cf\u6765\u4e3a\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u6784\u5efa\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u4e3a64\u4f4dLinux\u7cfb\u7edf\u6784\u5efa\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`shell<\/p>\n<p>export GOOS=linux<\/p>\n<p>export GOARCH=amd64<\/p>\n<p>go build -o app main.go<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u751f\u6210\u4e00\u4e2a\u540d\u4e3a`app`\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5c06\u6b64\u6587\u4ef6\u590d\u5236\u5230\u4efb\u4f55Li<a href=\"https:\/\/www.yimenexe.com\/exe-kaifa-2812.html\">\u751f\u6210exe\u6587\u4ef6\u4e2d\u7684\u6d4f\u89c8\u5668<\/a>nux 64\u4f4d\u7cfb\u7edf\u4e0a\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884c\u5373\u53ef\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u4f7f\u7528Golang\u521b\u5efaEXE\u6587\u4ef6\u7684\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd\u3002\u7f16\u5199Go\u7a0b\u5e8f\uff0c\u4f7f\u7528Go\u7f16\u8bd1\u5668\u7f16\u8bd1\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7136\u540e\u5728\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\uff0c\u8f7b\u677e\u5b9e\u73b0\u8de8\u5e73\u53f0\u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Golang\uff08Go\u8bed\u8a00\uff09\u521b\u5efa\u4e00\u6b3e\u7b80\u5355\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08EXE\uff09\u3002Go\u662f\u4e00\u79cd\u7f16\u8bd1\u578b\u7f16\u7a0b\u8bed\u8a00\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u53ef\u4ee5\u5c06\u6e90\u4ee3\u7801\u76f4\u63a5\u7f16\u8bd1\u4e3a\u673a\u5668\u7ea7\u522b\u7684\u4ee3\u7801\uff0c\u800c\u65e0\u9700\u5176\u4ed6\u8bed\u8a00\u7684\u89e3\u91ca\u5668\u3002\u7f16\u8bd1<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[18182,18183,8878,2708,1882],"special":[],"attr":[],"class_list":["post-22652","post","type-post","status-publish","format-standard","hentry","category-zixun","tag-seleniumexe","tag-swtexe","tag-8878","tag-2708","tag-1882","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/22652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/comments?post=22652"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/22652\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/media?parent=22652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/categories?post=22652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/tags?post=22652"},{"taxonomy":"special","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/special?post=22652"},{"taxonomy":"attr","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/attr?post=22652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}