{"id":1505,"date":"2020-09-18T06:00:39","date_gmt":"2020-09-17T22:00:39","guid":{"rendered":"https:\/\/www.develop-note.com\/blog\/?p=1505"},"modified":"2022-02-16T21:59:59","modified_gmt":"2022-02-16T13:59:59","slug":"go-basic-2021irionman","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2020\/09\/18\/go-basic-2021irionman\/","title":{"rendered":"Iris \u9019\u500b\u5728 go \u8a9e\u8a00\u4e0a\u5730\u8868\u6700\u5feb\u7684\u7db2\u9801\u6846\u67b6- go\u7684\u57fa\u790e\u4ecb\u7d39"},"content":{"rendered":"<h1>go\u7684\u57fa\u790e\u4ecb\u7d39<\/h1>\n<p>go\u7684\u57fa\u790e\u4ecb\u7d39 \u662f\u6211\u5011\u63a5\u4e0b\u4f86\u8981\u4ecb\u7d39\u7684\u5167\u5bb9\uff0c\u5b89\u88dd\u597d go \u7684\u61c9\u7528\u7a0b\u5f0f\u5f8c\uff0c\u63a5\u4e0b\u4f86\u8981\u8ddf\u5927\u5bb6\u521d\u6b65\u4ecb\u7d39\u4e00\u4e0b go \u8a9e\u8a00\u7684\u7279\u6027\u8b93\u5927\u5bb6\u5c0d\u65bc go \u8a9e\u8a00\u6709\u4e00\u4e9b\u521d\u6b65\u7684\u6982\u5ff5\uff0c\u4e86\u89e3\u4e00\u4e0b go \u8a9e\u8a00\u7684\u8a2d\u8a08\u7684\u6982\u5ff5\uff0c\u6240\u4ee5\u63a5\u4e0b\u4f86\u6703\u958b\u59cb\u3002<\/p>\n<p><!--more--><\/p>\n<h2>go \u662f OOP \u55ce<\/h2>\n<p>\u7b46\u8005\u5f88\u7fd2\u6163\u7684\u6bd4\u8f03\u7a0b\u5f0f\u8a9e\u8a00\u662f\u900f\u904e OOP \u6216\u662f functional \u9019\u5169\u500b\u7a2e\u4f86\u5340\u5206\u7a0b\u5f0f\u8a9e\u8a00\u7684\u985e\u5225\uff0c\u800c go \u662f\u54ea\u4e00\u985e?\u7b46\u8005\u8a8d\u70ba go \u662f\u6c92\u6709\u7e7c\u627f\u7684 OOP\u3002\u5728\u4ee5\u5f80\u591a\u91cd\u7e7c\u627f\u9019\u500b\u7279\u6027\u5728 OOP \u985e\u5225\u7684\u7a0b\u5f0f\u8a9e\u8a00\u4e2d\u5e38\u5e38\u88ab\u4eba\u5bb6\u6240\u8a6c\u75c5\uff0c\u7136\u800c\u5728 go \u4e4b\u4e2d\u6c92\u6709\u7e7c\u627f\u800c\u662f\u7528\u7d44\u6210(Composition)\u4f86\u53d6\u4ee3\u3002\u9664\u4e86\u7e7c\u627f\u4e4b\u5916\u5176\u4ed6 OOP \u7684\u6982\u5ff5\u5982\u62bd\u8c61\u3001\u5c01\u88dd\u3001\u591a\u5f62\u7684\u6982\u5ff5\u90fd\u9084\u4fdd\u6709\u5728 go \u5167\u6240\u4ee5\u7b46\u8005\u8a8d\u70ba go \u662f  OOP\u3002<\/p>\n<h2>go \u7684\u591a\u5f62<\/h2>\n<p>\u525b\u525b\u63d0\u5230 go \u7684 OOP \u7279\u6027\u5f8c\u63a5\u4e0b\u4f86\u5c31\u8981\u63d0\u4e00\u63d0 go \u65b9\u6cd5\u5be6\u4f5c\u7684\u7279\u6027\uff0c go \u662f\u4e0d\u5141\u8a31\u591a\u8f09\u7684\uff0c\u4e5f\u5c31\u662f go \u985e\u5225\u7684\u65b9\u6cd5\u4e0d\u5141\u8a31\u5169\u500b\u4ee5\u4e0a\u76f8\u540c\u540d\u5b50\u7684\u65b9\u6cd5\u5b58\u5728\u3002\u539f\u56e0\u662f\u591a\u8f09\u6703\u8b93\u958b\u767c\u7684\u4eba\u54e1\u6709\u641e\u6df7\u65b9\u6cd5\u7684\u6a5f\u6703\uff0c\u6240\u4ee5\u57fa\u65bc\u7c21\u55ae\u7684\u6982\u5ff5\u4e0b go \u9078\u64c7\u8b93\u958b\u767c\u7684\u4eba\u54e1\u540c\u4e00\u500b\u985e\u5225\u4e4b\u4e2d\u4e00\u500b\u540d\u7a31\u7684\u65b9\u6cd5\u53ea\u80fd\u505a\u4e00\u4ef6\u4e8b\u60c5\u3002<\/p>\n<h2>go \u7684\u985e\u5225<\/h2>\n<p>\u7167\u5b57\u9762\u4e0a\u4f86\u8b1b\uff0c go \u6c92\u6709\u985e\u5225\u9019\u5b9a\u7fa9\uff0cgo \u4e4b\u4e2d\u6709\u4e00\u500b\u8ddf\u985e\u5225\u5f88\u76f8\u8fd1\u7684\u5b9a\u7fa9\u5c31\u662f<code>struct<\/code>\uff0c\u76f8\u4fe1\u719f\u6089C\u8207C++\u7684\u8b80\u8005\u5011\u5c0d\u65bc\u9019\u500b\u95dc\u9375\u5b57\u61c9\u8a72\u4e0d\u964c\u751f\uff0c\u9019\u5c31\u662f\u5728C\u8a9e\u8a00\u4e4b\u4e2d\u8fd1\u4f3c\u985e\u5225\u7684\u95dc\u9375\u5b57\uff0c\u4f46\u662f\u9019\u500b\u6c92\u8fa6\u6cd5\u5728\u4e0a\u9762\u5be6\u4f5c\u65b9\u6cd5\uff0c\u56e0\u70ba\u4ed6\u4e0d\u662f\u985e\u5225\uff0c\u4e0d\u904e\u5728 go \u4e0d\u4e00\u6a23\uff0c\u53ef\u4ee5\u91dd\u5c0d\u9019\u500b<code>struct<\/code>\u5b9a\u7fa9\u4ed6\u7684\u65b9\u6cd5\uff0c\u9019\u90e8\u5206\u4e4b\u5f8c\u6703\u63d0\u5230\u3002<\/p>\n<h2>go \u7684\u4ecb\u9762<\/h2>\n<p>\u96d6\u7136 go \u4e0d\u80fd\u7e7c\u627f\uff0c\u4f46\u662f\u4ed6\u9084\u662f\u4fdd\u7559\u4ecb\u9762\u9019\u500b\u505a\u6cd5\uff0c\u53ef\u4ee5\u900f\u904e\u5ba3\u544a\u4ecb\u9762\u4f86\u5728\u7de8\u8b6f\u6642\u671f\u8981\u6c42\u985e\u5225\u4e00\u5b9a\u8981\u5be6\u4f5c\u5c0d\u61c9\u7684\u4ecb\u9762\uff0c\u9019\u6a23\u4e5f\u53ef\u4ee5\u5728\u7a0b\u5f0f\u958b\u767c\u6642\u76f8\u4f9d\u4ecb\u9762\u800c\u4e0d\u76f8\u4f9d\u985e\u5225\uff0c\u5982\u6b64\u8b93\u958b\u767c\u6642\u5c08\u6ce8\u5728\u7576\u4e0b\u7684\u65b9\u6cd5\u7684\u5be6\u4f5c\u3002<\/p>\n<h2>go \u662f\u5f37\u578b\u5225\u6216\u5f31\u578b\u5225<\/h2>\n<p>\u6240\u8b02\u5f37\u578b\u5225\u6216\u662f\u5f31\u578b\u5225\u7684\u5dee\u5225\u662f\u5728\u65bc\u8ce6\u503c\u6642\u662f\u5426\u6703\u5728\u610f\u8b8a\u6578\u7684\u578b\u5225\uff0c\u5f37\u578b\u5225\u5c31\u662f\u4e0d\u5141\u8a31\u8b8a\u6578\u8ce6\u4e88\u4e0d\u540c\u578b\u5225\u7684\u503c\uff0c\u4f8b\u5982 <code>go<\/code> \u8207 <code>python<\/code> \u3002<\/p>\n<p>\u800c\u5f31\u578b\u5225\u5247\u50cf <code>javascript<\/code> \u5247\u53ef\u4ee5\u4efb\u610f\u8ce6\u503c\u7d66\u8b8a\u6578\u3002<\/p>\n<h2>go \u7684\u7a0b\u5f0f\u5340\u584a\u53ca\u6bb5\u843d<\/h2>\n<p>go \u7684\u7a0b\u5f0f\u5340\u584a\u662f\u4ee5<code> {} <\/code>\u4f86\u4f5c\u70ba\u5340\u57df\u7684\u5340\u5206\uff0c\u4f8b\u5982\u65b9\u6cd5\u7684\u5340\u584a\u5167\u662f\u5340\u57df\u8b8a\u6578\uff0c\u53ea\u80fd\u5728\u5340\u57df\u5167\u4f7f\u7528\u3002<\/p>\n<p>go \u7684\u6bb5\u843d\u662f\u4ee5\u63db\u884c\u4f5c\u70ba\u8a72\u884c\u7684\u7d50\u675f\uff0c\u6240\u4ee5\u4e0d\u540c\u884c\u7684\u8996\u70ba\u53e6\u4e00\u6bb5\u8a9e\u8a00\u3002<\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u63a5\u8457<a href=\"\/blog\/2018\/10\/01\/2019ironman-flask-restful-day00\/\" title=\"flask\">flask<\/a>\u8207<a href=\"\/blog\/2019\/09\/02\/2020ironman-svelte-synopsis\/\" title=\"svelte\">svelte<\/a>\u9019\u662f\u7b46\u8005\u7684\u7b2c\u4e09\u7bc7\u7cfb\u5217\u6587\u7ae0\uff0c\u5e0c\u671b\u5c0d\u5927\u5bb6\u5b78\u7fd2go\u6709\u5e6b\u52a9\uff0c\u63a5\u4e0b\u4f86\u6703\u958b\u59cb\u4ecb\u7d39 go\u7684\u8a9e\u6cd5\uff0c\u5728\u9019\u4e4b\u524d\u6709\u8208\u8da3\u7684\u8b80\u8005\u5011\u53ef\u4ee5\u5148\u770b\u770b<a href=\"https:\/\/tour.golang.org\/welcome\/1\" title=\"go tour\" rel=\"nofollow noopener\" target=\"_blank\">go tour<\/a>\u5b78\u7fd2\u4e00\u4e0b go \u8a9e\u8a00\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>go\u7684\u57fa\u790e\u4ecb\u7d39 go\u7684\u57fa\u790e\u4ecb\u7d39 \u662f\u6211\u5011\u63a5\u4e0b\u4f86\u8981\u4ecb\u7d39\u7684\u5167\u5bb9\uff0c\u5b89\u88dd\u597d go \u7684\u61c9\u7528\u7a0b\u5f0f\u5f8c\uff0c\u63a5\u4e0b\u4f86\u8981\u8ddf\u5927\u5bb6\u521d\u6b65\u4ecb\u7d39\u4e00 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2020\/09\/18\/go-basic-2021irionman\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Iris \u9019\u500b\u5728 go \u8a9e\u8a00\u4e0a\u5730\u8868\u6700\u5feb\u7684\u7db2\u9801\u6846\u67b6- go\u7684\u57fa\u790e\u4ecb\u7d39\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[158,81],"class_list":["post-1505","post","type-post","status-publish","format-standard","hentry","category-develop","tag-2020ironman","tag-go"],"_links":{"self":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/comments?post=1505"}],"version-history":[{"count":11,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1505\/revisions"}],"predecessor-version":[{"id":2690,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1505\/revisions\/2690"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=1505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=1505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=1505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}