{"id":3790,"date":"2022-12-30T14:29:03","date_gmt":"2022-12-30T06:29:03","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=3790"},"modified":"2022-12-30T14:29:03","modified_gmt":"2022-12-30T06:29:03","slug":"%e6%b7%b1%e5%85%a5%e6%8e%a2%e8%a8%8ego%e8%aa%9e%e8%a8%80%e4%b8%ad%e7%9a%84%e8%ae%8a%e9%87%8f%e4%bd%9c%e7%94%a8%e5%9f%9f","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/go\/%e6%b7%b1%e5%85%a5%e6%8e%a2%e8%a8%8ego%e8%aa%9e%e8%a8%80%e4%b8%ad%e7%9a%84%e8%ae%8a%e9%87%8f%e4%bd%9c%e7%94%a8%e5%9f%9f\/","title":{"rendered":"\u6df1\u5165\u63a2\u8a0eGo\u8a9e\u8a00\u4e2d\u7684\u8b8a\u91cf\u4f5c\u7528\u57df"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Go, \u8b8a\u91cf\u4f5c\u7528\u57df\"><\/p>\n<p>Go \u8a9e\u8a00\u7684\u8b8a\u91cf\u4f5c\u7528\u57df\u662f\u4e00\u500b\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u597d\u5730\u63a7\u5236\u7a0b\u5f0f\u78bc\u7684\u53ef\u898b\u6027\u548c\u53ef\u7528\u6027\u3002\u5728 Go \u8a9e\u8a00\u4e2d\uff0c\u8b8a\u91cf\u4f5c\u7528\u57df\u53ef\u4ee5\u5206\u70ba\u5169\u7a2e\uff1a\u5168\u5c40\u8b8a\u91cf\u548c\u5c40\u90e8\u8b8a\u91cf\u3002\u5168\u5c40\u8b8a\u91cf\u53ef\u4ee5\u5728\u6574\u500b\u7a0b\u5f0f\u78bc\u4e2d\u4f7f\u7528\uff0c\u800c\u5c40\u90e8\u8b8a\u91cf\u53ea\u80fd\u5728\u5b83\u5011\u5ba3\u544a\u7684\u51fd\u6578\u6216\u4ee3\u78bc\u584a\u4e2d\u4f7f\u7528\u3002<\/p>\n<h2>\u5168\u5c40\u8b8a\u91cf<\/h2>\n<p>\u5168\u5c40\u8b8a\u91cf\u662f\u5ba3\u544a\u5728\u6574\u500b\u7a0b\u5f0f\u78bc\u4e2d\u7684\u8b8a\u91cf\uff0c\u5b83\u5011\u53ef\u4ee5\u5728\u4efb\u4f55\u51fd\u6578\u6216\u4ee3\u78bc\u584a\u4e2d\u4f7f\u7528\u3002\u5b83\u5011\u7684\u4f5c\u7528\u57df\u662f\u6574\u500b\u7a0b\u5f0f\u78bc\uff0c\u56e0\u6b64\u5b83\u5011\u53ef\u4ee5\u5728\u4efb\u4f55\u5730\u65b9\u88ab\u8a2a\u554f\u548c\u4fee\u6539\u3002<\/p>\n<pre class=\"brush: go\">\n\/\/ \u5ba3\u544a\u4e00\u500b\u5168\u5c40\u8b8a\u91cf\nvar globalVariable int\n\nfunc main() {\n    \/\/ \u5728 main \u51fd\u6578\u4e2d\u53ef\u4ee5\u8a2a\u554f\u548c\u4fee\u6539\u5168\u5c40\u8b8a\u91cf\n    globalVariable = 10\n}\n\nfunc foo() {\n    \/\/ \u5728 foo \u51fd\u6578\u4e2d\u4e5f\u53ef\u4ee5\u8a2a\u554f\u548c\u4fee\u6539\u5168\u5c40\u8b8a\u91cf\n    globalVariable = 20\n}\n<\/pre>\n<p><!--more--><\/p>\n<h2>\u5c40\u90e8\u8b8a\u91cf<\/h2>\n<p>\u5c40\u90e8\u8b8a\u91cf\u662f\u5ba3\u544a\u5728\u51fd\u6578\u6216\u4ee3\u78bc\u584a\u4e2d\u7684\u8b8a\u91cf\uff0c\u5b83\u5011\u53ea\u80fd\u5728\u5b83\u5011\u5ba3\u544a\u7684\u51fd\u6578\u6216\u4ee3\u78bc\u584a\u4e2d\u4f7f\u7528\u3002\u5b83\u5011\u7684\u4f5c\u7528\u57df\u53ea\u9650\u65bc\u5b83\u5011\u5ba3\u544a\u7684\u51fd\u6578\u6216\u4ee3\u78bc\u584a\uff0c\u56e0\u6b64\u5b83\u5011\u53ea\u80fd\u5728\u5b83\u5011\u5ba3\u544a\u7684\u51fd\u6578\u6216\u4ee3\u78bc\u584a\u4e2d\u88ab\u8a2a\u554f\u548c\u4fee\u6539\u3002<\/p>\n<pre class=\"brush: go\">\nfunc main() {\n    \/\/ \u5ba3\u544a\u4e00\u500b\u5c40\u90e8\u8b8a\u91cf\n    var localVariable int\n\n    \/\/ \u5728 main \u51fd\u6578\u4e2d\u53ef\u4ee5\u8a2a\u554f\u548c\u4fee\u6539\u5c40\u90e8\u8b8a\u91cf\n    localVariable = 10\n}\n\nfunc foo() {\n    \/\/ \u5728 foo \u51fd\u6578\u4e2d\u4e0d\u80fd\u8a2a\u554f\u548c\u4fee\u6539\u5c40\u90e8\u8b8a\u91cf\n    \/\/ localVariable = 20\n}\n<\/pre>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cGo \u8a9e\u8a00\u7684\u8b8a\u91cf\u4f5c\u7528\u57df\u53ef\u4ee5\u5206\u70ba\u5169\u7a2e\uff1a\u5168\u5c40\u8b8a\u91cf\u548c\u5c40\u90e8\u8b8a\u91cf\u3002\u5168\u5c40\u8b8a\u91cf\u53ef\u4ee5\u5728\u6574\u500b\u7a0b\u5f0f\u78bc\u4e2d\u4f7f\u7528\uff0c\u800c\u5c40\u90e8\u8b8a\u91cf\u53ea\u80fd\u5728\u5b83\u5011\u5ba3\u544a\u7684\u51fd\u6578\u6216\u4ee3\u78bc\u584a\u4e2d\u4f7f\u7528\u3002\u958b\u767c\u8005\u53ef\u4ee5\u6839\u64da\u81ea\u5df1\u7684\u9700\u6c42\u4f86\u9078\u64c7\u5408\u9069\u7684\u8b8a\u91cf\u4f5c\u7528\u57df\uff0c\u4ee5\u66f4\u597d\u5730\u63a7\u5236\u7a0b\u5f0f\u78bc\u7684\u53ef\u898b\u6027\u548c\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eGo\u8a9e\u8a00\u4e2d\u7684\u8b8a\u91cf\u4f5c\u7528\u57df\uff0c\u8a73\u7d30\u4ecb\u7d39Go\u8a9e\u8a00\u4e2d\u7684\u8b8a\u91cf\u4f5c\u7528\u57df\u7684\u5b9a\u7fa9\u3001\u7279\u6027\u3001\u512a\u9ede\u53ca\u5176\u5728\u958b\u767c\u4e2d\u7684\u61c9\u7528\uff0c\u8b93\u8b80\u8005\u66f4\u52a0\u4e86\u89e3Go\u8a9e\u8a00\u4e2d\u7684\u8b8a\u91cf\u4f5c\u7528\u57df\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[171,172],"tags":[169,170],"class_list":["post-3790","post","type-post","status-publish","format-standard","hentry","category-go","category-golang","tag-go","tag-golang"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-Z8","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/3790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=3790"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/3790\/revisions"}],"predecessor-version":[{"id":3791,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/3790\/revisions\/3791"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=3790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=3790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=3790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}