{"id":3694,"date":"2022-12-30T13:35:22","date_gmt":"2022-12-30T05:35:22","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=3694"},"modified":"2022-12-30T13:35:22","modified_gmt":"2022-12-30T05:35:22","slug":"%e5%ad%b8%e7%bf%92go%e8%aa%9e%e8%a8%80%e4%b8%ad%e7%9a%84%e6%8e%a5%e5%8f%a3%ef%bc%9a%e6%b7%b1%e5%85%a5%e4%ba%86%e8%a7%a3%e6%8e%a5%e5%8f%a3%e7%9a%84%e5%8a%9f%e8%83%bd%e8%88%87%e6%87%89%e7%94%a8","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/go\/%e5%ad%b8%e7%bf%92go%e8%aa%9e%e8%a8%80%e4%b8%ad%e7%9a%84%e6%8e%a5%e5%8f%a3%ef%bc%9a%e6%b7%b1%e5%85%a5%e4%ba%86%e8%a7%a3%e6%8e%a5%e5%8f%a3%e7%9a%84%e5%8a%9f%e8%83%bd%e8%88%87%e6%87%89%e7%94%a8\/","title":{"rendered":"\u5b78\u7fd2Go\u8a9e\u8a00\u4e2d\u7684\u63a5\u53e3\uff1a\u6df1\u5165\u4e86\u89e3\u63a5\u53e3\u7684\u529f\u80fd\u8207\u61c9\u7528"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Go, \u63a5\u53e3\"><\/p>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u662f\u4e00\u500b\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u69cb\u5efa\u51fa\u53ef\u91cd\u7528\u7684\u4ee3\u78bc\u3002\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u500b\u62bd\u8c61\u7684\u6982\u5ff5\u8f49\u63db\u70ba\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u4ee3\u78bc\u3002\u5728 Go \u8a9e\u8a00\u4e2d\uff0c\u63a5\u53e3\u662f\u4e00\u7a2e\u7279\u6b8a\u7684\u985e\u578b\uff0c\u5b83\u53ef\u4ee5\u5b9a\u7fa9\u4e00\u7d44\u65b9\u6cd5\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002<\/p>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u69cb\u5efa\u51fa\u53ef\u91cd\u7528\u7684\u4ee3\u78bc\u3002\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u500b\u62bd\u8c61\u7684\u6982\u5ff5\u8f49\u63db\u70ba\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u4ee3\u78bc\u3002\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u500b\u62bd\u8c61\u7684\u6982\u5ff5\u8f49\u63db\u70ba\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u4ee3\u78bc\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002<\/p>\n<h2>Go \u8a9e\u8a00\u63a5\u53e3\u7684\u57fa\u672c\u6982\u5ff5<\/h2>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u662f\u4e00\u7a2e\u7279\u6b8a\u7684\u985e\u578b\uff0c\u5b83\u53ef\u4ee5\u5b9a\u7fa9\u4e00\u7d44\u65b9\u6cd5\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u500b\u62bd\u8c61\u7684\u6982\u5ff5\u8f49\u63db\u70ba\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u4ee3\u78bc\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002<\/p>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u53ef\u4ee5\u88ab\u7528\u4f86\u5b9a\u7fa9\u4e00\u500b\u985e\u578b\u7684\u884c\u70ba\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002\u63a5\u53e3\u53ef\u4ee5\u88ab\u7528\u4f86\u5b9a\u7fa9\u4e00\u500b\u985e\u578b\u7684\u884c\u70ba\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002\u4f8b\u5982\uff0c\u4e00\u500b\u63a5\u53e3\u53ef\u4ee5\u5b9a\u7fa9\u4e00\u500b\u985e\u578b\u7684\u884c\u70ba\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: go\">\ntype MyInterface interface {\n    DoSomething()\n    DoSomethingElse()\n}\n<\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u78bc\u5b9a\u7fa9\u4e86\u4e00\u500b\u63a5\u53e3\uff0c\u5b83\u6709\u5169\u500b\u65b9\u6cd5\uff1aDoSomething() \u548c DoSomethingElse()\u3002\u4efb\u4f55\u985e\u578b\u90fd\u53ef\u4ee5\u5be6\u73fe\u9019\u500b\u63a5\u53e3\uff0c\u53ea\u8981\u5b83\u5be6\u73fe\u4e86\u9019\u5169\u500b\u65b9\u6cd5\u3002<\/p>\n<p><!--more--><\/p>\n<h2>Go \u8a9e\u8a00\u63a5\u53e3\u7684\u5be6\u73fe<\/h2>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u53ef\u4ee5\u88ab\u7528\u4f86\u5b9a\u7fa9\u4e00\u500b\u985e\u578b\u7684\u884c\u70ba\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002\u4e00\u500b\u985e\u578b\u53ef\u4ee5\u5be6\u73fe\u4e00\u500b\u63a5\u53e3\uff0c\u53ea\u8981\u5b83\u5be6\u73fe\u4e86\u63a5\u53e3\u4e2d\u5b9a\u7fa9\u7684\u6240\u6709\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u4e00\u500b\u985e\u578b\u53ef\u4ee5\u5be6\u73fe MyInterface \u63a5\u53e3\uff0c\u53ea\u8981\u5b83\u5be6\u73fe\u4e86 DoSomething() \u548c DoSomethingElse() \u65b9\u6cd5\uff1a<\/p>\n<pre class=\"brush: go\">\ntype MyType struct {\n    \/\/ ...\n}\n\nfunc (t *MyType) DoSomething() {\n    \/\/ ...\n}\n\nfunc (t *MyType) DoSomethingElse() {\n    \/\/ ...\n}\n\nvar _ MyInterface = (*MyType)(nil)\n<\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u78bc\u5b9a\u7fa9\u4e86\u4e00\u500b MyType \u985e\u578b\uff0c\u5b83\u5be6\u73fe\u4e86 MyInterface \u63a5\u53e3\uff0c\u56e0\u70ba\u5b83\u5be6\u73fe\u4e86\u63a5\u53e3\u4e2d\u5b9a\u7fa9\u7684\u6240\u6709\u65b9\u6cd5\u3002<\/p>\n<h2>Go \u8a9e\u8a00\u63a5\u53e3\u7684\u512a\u9ede<\/h2>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u69cb\u5efa\u51fa\u53ef\u91cd\u7528\u7684\u4ee3\u78bc\u3002\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u500b\u62bd\u8c61\u7684\u6982\u5ff5\u8f49\u63db\u70ba\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u4ee3\u78bc\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002<\/p>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u9084\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u69cb\u5efa\u51fa\u53ef\u64f4\u5c55\u7684\u4ee3\u78bc\u3002\u63a5\u53e3\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u500b\u62bd\u8c61\u7684\u6982\u5ff5\u8f49\u63db\u70ba\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u4ee3\u78bc\uff0c\u800c\u4e0d\u9700\u8981\u63d0\u4f9b\u4efb\u4f55\u5be6\u73fe\u3002\u9019\u6a23\u4e00\u4f86\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u69cb\u5efa\u51fa\u53ef\u64f4\u5c55\u7684\u4ee3\u78bc\uff0c\u56e0\u70ba\u4ed6\u5011\u53ef\u4ee5\u5c07\u62bd\u8c61\u7684\u6982\u5ff5\u8f49\u63db\u70ba\u53ef\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u4ee3\u78bc\u3002<\/p>\n<p>Go \u8a9e\u8a00\u7684\u63a5\u53e3\u662f\u4e00\u500b\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u69cb\u5efa\u51fa\u53ef\u91cd\u7528\u7684\u4ee3\u78bc\uff0c\u4e26\u4e14\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u69cb\u5efa\u51fa\u53ef\u64f4\u5c55\u7684\u4ee3\u78bc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go\u8a9e\u8a00\u4e2d\u7684\u63a5\u53e3\u662f\u4e00\u7a2e\u7279\u6b8a\u7684\u985e\u578b\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u5c07\u4e0d\u540c\u7684\u985e\u578b\u7d44\u5408\u5728\u4e00\u8d77\uff0c\u4e26\u63d0\u4f9b\u66f4\u591a\u7684\u7075\u6d3b\u6027\u3002\u672c\u6587\u5c07\u6df1\u5165\u89e3\u91cb\u63a5\u53e3\u7684\u529f\u80fd\uff0c\u4ee5\u53ca\u5982\u4f55\u5728Go\u8a9e\u8a00\u4e2d\u4f7f\u7528\u5b83\u5011\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-3694","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-XA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/3694","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=3694"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/3694\/revisions"}],"predecessor-version":[{"id":3695,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/3694\/revisions\/3695"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=3694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=3694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=3694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}