{"id":15462,"date":"2024-11-18T18:11:29","date_gmt":"2024-11-18T10:11:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=15462"},"modified":"2024-11-18T18:11:29","modified_gmt":"2024-11-18T10:11:29","slug":"go%e4%b8%adnew-%e5%92%8c-make%e7%9a%84%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/15462\/","title":{"rendered":"GO\u4e2dnew \u548c make\u7684\u533a\u522b"},"content":{"rendered":"<h3><strong>\u4e00\u3001make<\/strong><\/h3>\n<p>make \u53ea\u80fd\u4e3a slice\u3001map\u6216 channel \u7c7b\u578b\u5206\u914d\u5185\u5b58\u5e76\u521d\u59cb\u5316\uff0c\u540c\u65f6\u8fd4\u56de\u4e00\u4e2a\u6709\u521d\u59cb\u503c\u7684 slice\u3001map \u6216 channel \u7c7b\u578b\u5f15\u7528\uff0c\u4e0d\u662f\u6307\u9488\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u901a\u8fc7\u4e0b\u8868\u518d\u6765\u770b make \u7684\u5177\u4f53\u5e94\u7528\uff1a<\/p>\n<table border=\"1\" cellspacing=\"5\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"20%\">Call<\/td>\n<td valign=\"top\" width=\"10%\">Type T<\/td>\n<td valign=\"top\">Result<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">make(T, n)<\/td>\n<td valign=\"top\">slice<\/td>\n<td valign=\"top\">slice of type T with length n and capacity n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">make(T, n, m)<\/td>\n<td valign=\"top\">slice<\/td>\n<td valign=\"top\">slice of type T with length n and capacity m<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">make(T)<\/td>\n<td valign=\"top\">map<\/td>\n<td valign=\"top\">map of type T<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">make(T, n)<\/td>\n<td valign=\"top\">map<\/td>\n<td valign=\"top\">map of type T with initial space for n elements<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">make(T)<\/td>\n<td valign=\"top\">channel<\/td>\n<td valign=\"top\">unbuffered channel of type T<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">make(T, n)<\/td>\n<td valign=\"top\">channel<\/td>\n<td valign=\"top\">buffered channel of type T, buffer<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Tips : \u5bf9\u4e8emake slice\u800c\u8a00\uff0c\u6709\u4e24\u4e2a\u6982\u5ff5\u9700\u8981\u641e\u6e05\u695a\uff1a\u957f\u5ea6\u8ddf\u5bb9\u91cf\u3002<\/strong><\/p>\n<ul>\n<li>\u5bb9\u91cf\u8868\u793a\u5e95\u5c42\u6570\u7ec4\u7684\u5927\u5c0f\uff0c\u957f\u5ea6\u662f\u4f60\u53ef\u4ee5\u4f7f\u7528\u7684\u5927\u5c0f\u3002<\/li>\n<li>\u5bb9\u91cf\u7684\u7528\u5904\u5728\u54ea\uff1f\u5728\u4e0e\u5f53\u4f60\u7528 appen d\u6269\u5c55\u957f\u5ea6\u65f6\uff0c\u5982\u679c\u65b0\u7684\u957f\u5ea6\u5c0f\u4e8e\u5bb9\u91cf\uff0c\u4e0d\u4f1a\u66f4\u6362\u5e95\u5c42\u6570\u7ec4\uff0c\u5426\u5219\uff0cgo \u4f1a\u65b0\u7533\u8bf7\u4e00\u4e2a\u5e95\u5c42\u6570\u7ec4\uff0c\u62f7\u8d1d\u8fd9\u8fb9\u7684\u503c\u8fc7\u53bb\uff0c\u628a\u539f\u6765\u7684\u6570\u7ec4\u4e22\u6389\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bb9\u91cf\u7684\u7528\u9014\u662f\uff1a\u5728\u6570\u636e\u62f7\u8d1d\u548c\u5185\u5b58\u7533\u8bf7\u7684\u6d88\u8017\u4e0e\u5185\u5b58\u5360\u7528\u4e4b\u95f4\u63d0\u4f9b\u4e00\u4e2a\u6743\u8861\u3002<\/li>\n<li>\u800c\u957f\u5ea6\uff0c\u5219\u662f\u4e3a\u4e86\u5e2e\u52a9\u4f60\u9650\u5236\u5207\u7247\u53ef\u7528\u6210\u5458\u7684\u6570\u91cf\uff0c\u63d0\u4f9b\u8fb9\u754c\u67e5\u8be2\u7684\u3002\u6240\u4ee5\u7528 make \u7533\u8bf7\u597d\u7a7a\u95f4\u540e\uff0c\u9700\u8981\u6ce8\u610f\u4e0d\u8981\u8d8a\u754c\u3010\u8d8a len \u3011<\/li>\n<\/ul>\n<h3>\u00a0\u4e8c\u3001new<\/h3>\n<p>\u5185\u5efa\u51fd\u6570 new \u7528\u6765\u5206\u914d\u5185\u5b58\uff0c\u5b83\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u4e00\u4e2a\u7c7b\u578b\uff0c\u4e0d\u662f\u4e00\u4e2a\u503c\uff0c\u5b83\u7684\u8fd4\u56de\u503c\u662f\u4e00\u4e2a\u6307\u5411\u65b0\u5206\u914d\u7c7b\u578b\u96f6\u503c\u7684\u6307\u9488<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001make make \u53ea\u80fd\u4e3a slice\u3001map\u6216 channel \u7c7b\u578b\u5206\u914d\u5185\u5b58\u5e76\u521d\u59cb\u5316\uff0c\u540c\u65f6\u8fd4\u56de\u4e00\u4e2a\u6709\u521d\u59cb\u503c\u7684 slice\u3001map \u6216 channel \u7c7b\u578b\u5f15\u7528\uff0c\u4e0d\u662f\u6307\u9488\u3002 &nbsp; \u901a\u8fc7\u4e0b\u8868\u518d\u6765\u770b make \u7684\u5177\u4f53\u5e94\u7528\uff1a Call Type T Result make(T, n) slice slice of type T with length n and capacity n make(T, n, m) slice slice of type T with length n and capacity m make(T) map map of type T make(T, n) map map [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-15462","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=15462"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15462\/revisions"}],"predecessor-version":[{"id":15463,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15462\/revisions\/15463"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=15462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=15462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=15462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}