{"id":11340,"date":"2023-02-09T16:03:23","date_gmt":"2023-02-09T08:03:23","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=11340"},"modified":"2023-02-10T16:01:26","modified_gmt":"2023-02-10T08:01:26","slug":"go-23","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/02\/09\/go-23\/","title":{"rendered":"go\u8bed\u8a00\u4e4b\u6cdb\u578b"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4ec0\u4e48\u662f\u6cdb\u578b\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6cdb\u578b\u53ef\u4ee5\u7406\u89e3\u4e3a\u5728\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\uff0c\u5b9a\u4e49\u7684\u51fd\u6570\u3001\u65b9\u6cd5\u65f6\u4e0d\u9700\u8981\u6307\u5b9a\u7c7b\u578b\uff0c\u7c7b\u578b\u6839\u636e\u5177\u4f53\u7684\u8c03\u7528\u53c2\u6570\u6765\u6307\u5b9a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u4e0b\u9762\u4f8b\u5b50\u5b9a\u4e49\u51fd\u6570\uff0c\u53c2\u6570\u4e3a\u7a7a\u63a5\u53e3\u5207\u7247\uff0c\u8c03\u7528\u51fd\u51fd\u6570\uff0c\u904d\u5386\u5207\u7247\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"298\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-1.png\" alt=\"\" class=\"wp-image-11344\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-1.png 709w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-1-300x126.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-1-600x252.png 600w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@VM-12-12-centos gong]# go run fan.go \n# command-line-arguments\n.\/fan.go:13:6: cannot use &#91;]string{\u2026} (value of type &#91;]string) as type &#91;]interface{} in argument to fan\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u9762\u770b\u51fa\uff0c\u6267\u884c\u7ed3\u679c\u51fa\u9519\uff0c\u539f\u56e0\u662f\u867d\u7136\u7a7a\u63a5\u53e3(interface{})\u53ef\u4ee5\u63a5\u53d7\u4efb\u4f55\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4f46\u662f\u5728\u548c\u5207\u7247\u548c\u6620\u5c04\u914d\u5408\u7684\u65f6\u5019\uff0c\u65e0\u6cd5\u5c06[]T\u8f6c\u6362\u4e3a[]interface{}\u4e5f\u4e0d\u80fd\u5c06map[string]T\u8f6c\u6362\u4e3amap[string]interface{}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4f7f\u7528\u6cdb\u578b<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u91cd\u65b0\u4fee\u6539\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u58f0\u660e\u4e00\u4e2a\u6cdb\u578b\u51fd\u6570\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"333\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-1.png\" alt=\"\" class=\"wp-image-11351\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-1.png 709w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-1-300x141.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-1-600x282.png 600w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7b2c6\u884c\uff1a\u5728\u51fd\u6570\u540dfan\u548c\u62ec\u53f7\u4e2d\u95f4\u52a0\u4e86\u4e00\u5bf9\u4e2d\u62ec\u53f7[T any]\uff0c\u91cc\u9762\u53c2\u6570\u4e3aT\uff0c\u7c7b\u578b\u4e3aany\uff0c\u8868\u793a\u652f\u6301\u4efb\u610f\u53c2\u6570\uff0c\u540e\u9762\u7684\u51fd\u6570\u53c2\u6570s\u7684\u7c7b\u578b\u5219\u4e3a[]T\uff0c\u8fd9\u4e2aT\u5c31\u662f\u524d\u9762\u7684\u4e2d\u62ec\u53f7\u4e2d\u7684T\uff0c\u8868\u793a\u7c7b\u578b\uff0c\u6ce8\u610f\uff1a\u4e2d\u62ec\u53f7\u91cc\u7684\u53c2\u6570\u4e0d\u4e00\u5b9a\u4e3aT\uff0c\u5199A\u4e5f\u884c\u5199B\u4e5f\u884c\uff0c\u4f46\u662f\u7c7b\u578b\u5fc5\u987b\u5199any\uff0c\u5426\u5219\u62a5\u9519\uff0cany\u4e3a\u81ea\u5e26\u5173\u952e\u5b57<\/li><li>13-15\u884c\uff1a\u8c03\u7528\u51fd\u6570\uff0c12\u300113\u884c\u4e2d\u51fd\u6570\u540dfan\u540e\u5199\u4e86\u4e00\u5bf9\u4e2d\u62ec\u53f7\uff0c\u62ec\u53f7\u4e2d\u4e3a\u8981\u4f20\u9012\u7684\u7c7b\u578b\uff0c\u5bf9\u5e94\u7684\u5c31\u662fany\u7684\u503c\uff0c\u6b64\u4e2d\u62ec\u53f7\u53ef\u5199\u53ef\u4e0d\u5199\uff0c15\u884c\u4e2d\u5c31\u7701\u7565\u4e86\uff0c\u6ca1\u6709\u5199<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"714\" height=\"268\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-1.png\" alt=\"\" class=\"wp-image-11349\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-1.png 714w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-1-300x113.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-1-600x225.png 600w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/figure>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background wp-block-paragraph\">any\u53ef\u4ee5\u770b\u505ainterface{}\u7684\u522b\u540d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u58f0\u660e\u4e00\u4e2a\u6cdb\u578b\u5207\u7247\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"415\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-1.png\" alt=\"\" class=\"wp-image-11356\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-1.png 710w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-1-300x175.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-1-600x351.png 600w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7b2c6\u884c\uff1a\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u540d\u5b57\u4e3afans\uff0c\u7c7b\u578b\u4e3a\u5207\u7247\uff0c\u5e76\u4f7f\u7528\u4e86\u6cdb\u578b<\/li><li>15\u300118\u884c\uff1a\u5b9e\u4f8b\u5316\u53d8\u91cf\u7684\u65f6\u5019\uff0c\u9700\u8981\u6307\u5b9a\u7c7b\u578b\uff0c\u4e5f\u5c31\u662ffans\u540e\u9762\u9700\u8981\u52a0\u4e0a[int]\u624d\u53ef\u4ee5<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"120\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14.png\" alt=\"\" class=\"wp-image-11359\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14.png 708w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14-300x51.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14-600x102.png 600w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u58f0\u660e\u4e00\u4e2a\u6cdb\u578b\u901a\u9053\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"352\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/6-2.png\" alt=\"\" class=\"wp-image-11378\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/6-2.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/6-2-300x149.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/6-2-600x299.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"64\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/5-1.png\" alt=\"\" class=\"wp-image-11379\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/5-1.png 710w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/5-1-300x27.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/5-1-600x54.png 600w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u58f0\u660e\u4e00\u4e2a\u6cdb\u578bmap\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"374\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15.png\" alt=\"\" class=\"wp-image-11361\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15.png 708w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15-300x158.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15-600x317.png 600w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7b2c6\u884c\uff1a\u5b9a\u4e49map\u7c7b\u578b\u53d8\u91cffans\u4e2dk\u7684\u7c7b\u578b\u4e3astring\uff0cv\u7684\u7c7b\u578b\u4f7f\u7528\u6cdb\u578bany<\/li><li>13\u300116\u884c\uff1a\u5b9e\u4f8b\u5316\u53d8\u91cffans\uff0c\u6307\u5b9a\u6cdb\u578b\u7c7b\u578b\u4ee5\u53camap\u7684k\u548cv<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"88\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/1-1.png\" alt=\"\" class=\"wp-image-11364\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/1-1.png 708w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/1-1-300x37.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/1-1-600x75.png 600w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u5c06\u7b2c6\u884c\u548c\u7b2c9\u884c\u4e2d\u7684string\u4e5f\u6539\u4e3aany\u4f1a\u600e\u4e48\u6837\uff1f\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"396\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/2-1.png\" alt=\"\" class=\"wp-image-11368\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/2-1.png 709w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/2-1-300x168.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/2-1-600x335.png 600w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"102\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/3-1.png\" alt=\"\" class=\"wp-image-11369\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/3-1.png 708w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/3-1-300x43.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/3-1-600x86.png 600w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u62a5\u9519\u5185\u5bb9\u4e3a\u7f3a\u5c11\u53ef\u6bd4\u8f83\u7ea6\u675f\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f\u56e0\u4e3agolang\u6cdb\u578b\u5bf9\u4e8emap\u7684key\u6709\u5982\u4e0b\u7ea6\u675f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>key\u7684\u7c7b\u578b\u5fc5\u987b\u662f\u53ef\u4ee5\u6bd4\u8f83\u7684\uff0c\u6bd4\u8f83\u8fd0\u7b97\u7b26\u4e3a==\u548c!=<\/li><li>key\u7684\u7c7b\u578b\u4e0d\u80fd\u662ffunction\u3001map\u3001slice\uff08\u8fd9\u51e0\u4e2a\u4e0d\u53ef\u6bd4\u8f83\uff09<\/li><li>\u5bf9\u4e8einterface\u7c7b\u578b\uff0c\u5176\u52a8\u6001\u7c7b\u578b\u5fc5\u987b\u53ef\u8fdb\u884c\u6bd4\u8f83<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u53ef\u6bd4\u8f83\u7684\u7c7b\u578b\u6709<\/mark><\/strong>\uff1a\u5e03\u5c14\u3001\u6574\u6570\u3001\u6d6e\u70b9\u3001\u5b57\u7b26\u4e32\u3001\u6307\u9488\u3001channel\u3001interface\u3001complex\uff0c\u4ee5\u53ca\u4ed6\u4eec\u7ec4\u6210\u7684\u7ed3\u6784\u4f53\u3001\u6570\u7ec4\u3002\u6bd4\u8f83\u662f==\u548c!=\u6bd4\u8f83\uff0c\u4e0d\u6d89\u53ca\u5927\u5c0f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u4e0d\u53ef\u6bd4\u8f83\u7c7b\u578b\u6709<\/mark><\/strong>: function\u3001map\u3001slice\uff0c\u4ee5\u53ca\u4ed6\u4eec\u7ec4\u6210\u7684\u7ed3\u6784\u4f53\u548c\u6570\u7ec4\u3002\u6bd4\u8f83\u662f==\u548c!=\u6bd4\u8f83\uff0c\u4e0d\u6d89\u53ca\u5927\u5c0f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6cdb\u578b\u7ea6\u675f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6cdb\u578b\u7ea6\u675f\u6307\u7684\u662f\u7ea6\u675f\u6cdb\u578b\u6240\u80fd\u63a5\u53d7\u7684\u6570\u636e\u7c7b\u578b\uff0c\u66f4\u76f4\u767d\u7684\u8bf4\u5c31\u662f\u8fd9\u4e2a T \u53ef\u4ee5\u6307\u4ee3\u7684\u6570\u636e\u7c7b\u578b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e09\u4e2a\u7279\u6b8a\u7684 \u6cdb\u578b\u7ea6\u675f<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>any\uff1a\u4efb\u4f55\u6570\u636e\u7c7b\u578b<\/li><li>comparable\uff1a\u53ef\u4ee5\u7ecf\u884c\u6bd4\u8f83\u7684\u6570\u636e\u7c7b\u578b\uff08==, \u2260\uff09<\/li><li>Ordered\uff1a\u53ef\u4ee5\u8fdb\u884c\u5927\u5c0f\u5224\u65ad\u7684\u6570\u636e\u7c7b\u578b\uff08&lt;, >, \u2264, \u2265\uff09<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u4e0b\u9762\u4f8b\u5b50\u4f7f\u7528interface\u4e2d\u89c4\u5b9a\u7684\u7c7b\u578b\u7ea6\u675f\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"449\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-2.png\" alt=\"\" class=\"wp-image-11381\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-2.png 710w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-2-300x190.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/7-2-600x379.png 600w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7b2c8\u884c\uff1a\u5b9a\u4e49comp\u63a5\u53e3\uff0c\u6b64\u63a5\u53e3\u4e2d\u5b9a\u4e49\u7684\u7ea6\u675f\u7c7b\u578b\u53ea\u80fd\u4e3aint \u3001string\u3001int16\u4e09\u79cd<\/li><li>\u7b2c9\u884c\uff1a\u6b64\u79cd\u5199\u6cd5\u8868\u793a\u4e00\u4e2a\u7c7b\u578b\u96c6\uff0c\u5b9a\u4e49\u6cdb\u578b\u7684\u65f6\u5019\u6cdb\u578b\u79cd\u7c7b\u5fc5\u987b\u5c5e\u4e8e\u5176\u4e2d\u67d0\u4e00\u79cd<\/li><li>\u7b2c6\u884c\u548c\u7b2c13\u884c\uff1a\u4f7f\u7528comp\u63a5\u53e3\u4e2d\u7684\u7c7b\u578b<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"75\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/8-2.png\" alt=\"\" class=\"wp-image-11384\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/8-2.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/8-2-300x32.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/8-2-600x64.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u4fee\u6539\u7b2c\u4e00\u6b65\u4e2d\u4ee3\u7801\uff0c\u6dfb\u52a0\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u8c03\u7528\u65f6\u5019\u6307\u5b9a\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"536\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/9-2.png\" alt=\"\" class=\"wp-image-11386\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/9-2.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/9-2-300x227.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/9-2-600x455.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7b2c6\u884c\uff1a\u81ea\u5b9a\u4e49\u53d8\u91cfSelfInt\uff0c\u5e95\u5c42\u7684\u7c7b\u578b\u4e3aint16<\/li><li>\u7b2c21\u884c\uff1a\u5b9e\u4f8b\u5316\u53d8\u91cffmap\u65f6\uff0c\u4f20\u9012\u7c7b\u578bSelfInt<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u7ed3\u679c\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/fan.go:23:5: SelfInt does not implement comp (possibly missing ~ for int16 in constraint comp)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u8ff0\u9519\u8bef\u770b\u51fa\uff0c\u62a5\u9519\u539f\u56e0\u8bf4\u662fint16\u7c7b\u578b\u7f3a\u5c11~\uff0c\u5982\u679c\u4e0d\u52a0~\uff0c\u53ea\u6709int16\uff0c\u90a3\u4e48\u8868\u793a\u4f20\u9012\u7684\u7c7b\u578b\u5fc5\u987b\u4e3aint16\uff0c\u4f46\u662f\u5982\u679c\u52a0\u4e86~\uff0c\u90a3\u4e48\u4f20\u9012\u7684\u7c7b\u578b\u53ef\u4ee5\u662fint16\u7684\u6240\u6709\u7c7b\u578b\u7684\u96c6\u5408\uff0cSelfInt\u7684\u5e95\u5c42\u662fint16\uff0c\u56e0\u6b64\u5982\u679c\u8981\u4f20\u9012SelfInt\uff0c\u9700\u8981\u5728int16\u524d\u9762\u52a0\u4e0a~<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539\u4e0a\u8ff0\u4ee3\u7801\uff0c\u5c06int16\u6539\u4e3a~int16\uff0c\u518d\u6b21\u6267\u884c\u6253\u5370\u7ed3\u679c\u5373\u53ef\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"537\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-2.png\" alt=\"\" class=\"wp-image-11390\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-2.png 710w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-2-300x227.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/10-2-600x454.png 600w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background wp-block-paragraph\">\u6ce8\u610f\uff1a\u5efa\u8bae\u5c06int\u3001string\u8fd9\u4e9b\u524d\u9762\u90fd\u52a0\u4e0a~\uff0c\u4ee5\u9632\u51fa\u9519<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u9644\u52a0\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u8fd8\u53ef\u4ee5\u5c06\u4e0a\u8ff0\u7684\u7c7b\u578b\u96c6\u5206\u5f00\u5728\u591a\u4e2ainterface\u4e2d\u5199\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"437\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-2.png\" alt=\"\" class=\"wp-image-11395\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-2.png 711w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-2-300x184.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/11-2-600x369.png 600w\" sizes=\"auto, (max-width: 711px) 100vw, 711px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u65b9\u6cd5\u4e0d\u652f\u6301\u6cdb\u578b\uff0c\u4e0b\u56fe\u4e2d\u5199\u6cd5\u5c31\u662f\u9519\u8bef\u7684\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"371\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/12-2.png\" alt=\"\" class=\"wp-image-11397\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/12-2.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/12-2-300x157.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/12-2-600x315.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\u7684[T any]\u5199\u7684\u4f4d\u7f6e\u662f\u4e0d\u5bf9\u7684\uff0c\u56e0\u4e3a\u65b9\u6cd5\u662f\u4e0d\u652f\u6301\u4f7f\u7528\u6cdb\u578b\uff0c\u6539\u9020\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"405\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-2.png\" alt=\"\" class=\"wp-image-11398\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-2.png 709w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-2-300x171.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/13-2-600x343.png 600w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6539\u9020\u540e\u7684\u65b9\u6cd5\u4e2d\u867d\u7136\u4e5f\u6709\u6cdb\u578b\u7684\u5b58\u5728\uff0c\u4f46\u662f\u8fd9\u4e2a\u6cdb\u578b\u4f9d\u8d56\u7684\u662f\u4e0a\u9762\u7ed3\u6784\u4f53\u800c\u5b58\u5728\uff0c\u4e0d\u662f\u4f9d\u8d56\u4e8eperson()\u65b9\u6cd5\u5b58\u5728\u7684\uff0c\u56e0\u6b64\u6539\u9020\u540e\u7684\u6cdb\u578b\u662f\u6b63\u786e\u7684\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"63\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14-1.png\" alt=\"\" class=\"wp-image-11399\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14-1.png 709w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14-1-300x27.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/14-1-600x53.png 600w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6cdb\u578b\u548c\u63a5\u53e3<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type  abc interface {\n    hello()string\n}\ntype def interface{\n    ~int | ~string\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b98\u65b9\u7ed9\u51fa\u7684\u8bf4\u660e\u4e3a\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u53ea\u6709\u65b9\u6cd5\u7684\u63a5\u53e3\u53eb\u505a\u57fa\u672c\u63a5\u53e3(<strong>Basic Interface<\/strong>)<\/li><li>\u5305\u542b\u7c7b\u578b\u7ea6\u675f\u7684\u63a5\u53e3\u53eb\u505a\u4e00\u822c\u63a5\u53e3(<strong>General Interface<\/strong>)&#8212;\u65e0\u8bba\u662f\u5426\u5305\u542b\u65b9\u6cd5<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u4f7f\u7528\u6cdb\u578b\u81ea\u5e26\u7684comparable\u8fdb\u884c\u7ea6\u675f\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"355\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15-1.png\" alt=\"\" class=\"wp-image-11403\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15-1.png 707w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15-1-300x151.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/15-1-600x301.png 600w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\u8c03\u7528\u51fd\u6570\uff0c\u904d\u5386\u5207\u7247a\uff0c\u904d\u5386\u7684\u503c\u4e0e\u4f20\u9012\u7684\u53d8\u91cfb\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982\u679c\u76f8\u7b49\u5219\u8fd4\u56de\u5207\u7247\u5143\u7d20\u5bf9\u5e94\u7684\u7d22\u5f15\uff0c\u5426\u5219\u8fd4\u56de-1<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"74\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/16.png\" alt=\"\" class=\"wp-image-11405\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/16.png 710w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/16-300x31.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/02\/16-600x63.png 600w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662f\u6cdb\u578b\uff1f \u6cdb\u578b\u53ef\u4ee5\u7406\u89e3\u4e3a\u5728\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\uff0c\u5b9a\u4e49\u7684\u51fd\u6570\u3001\u65b9\u6cd5\u65f6\u4e0d\u9700\u8981\u6307\u5b9a\u7c7b\u578b\uff0c\u7c7b\u578b\u6839\u636e\u5177\u4f53\u7684\u8c03\u7528\u53c2\u6570\u6765\u6307\u5b9a 1\u3001 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":11341,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111,23],"tags":[],"class_list":["post-11340","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go","category-rong"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/11340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=11340"}],"version-history":[{"count":39,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/11340\/revisions"}],"predecessor-version":[{"id":11406,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/11340\/revisions\/11406"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/11341"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=11340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=11340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=11340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}