{"id":156190,"date":"2020-09-17T02:09:33","date_gmt":"2020-09-16T18:09:33","guid":{"rendered":"http:\/\/4563.org\/?p=156190"},"modified":"2020-09-17T02:09:33","modified_gmt":"2020-09-16T18:09:33","slug":"%e6%b1%82%e9%97%ae-go-%e8%ae%be%e7%bd%ae%e7%bb%93%e6%9e%84%e4%bd%93%e5%b1%9e%e6%80%a7%e7%9a%84%e6%a0%b7%e5%bc%8f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=156190","title":{"rendered":"\u6c42\u95ee Go \u8bbe\u7f6e\u7ed3\u6784\u4f53\u5c5e\u6027\u7684\u6837\u5f0f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u95ee Go \u8bbe\u7f6e\u7ed3\u6784\u4f53\u5c5e\u6027\u7684\u6837\u5f0f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hjahgdthab750 <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5b9e\u9645\u5728\u7528\u7684\u65f6\u5019\u4f3c\u4e4e\u6709\u4e24\u79cd\u5f62\u5f0f\uff0c\u4f46\u662f\u4e0d\u77e5\u9053\u90a3\u79cd\u66f4\u4f18\u6216\u8005\u5404\u81ea\u7684\u573a\u666f<\/p>\n<pre><code>type A  {   X string   B string }  func (a *A) SetX (error) {}  func (a A) GetX (string,error) {}  func NewA()  {    a = A{}    \/\/ \u7b2c\u4e00\u79cd    a.X,err = a.GetX()    \/\/ \u7b2c\u4e8c\u79cd    err := SetX() } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3320551\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : hjahgdthab750 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u60f3\u5230\u4e00\u4e2a a.GetX()\u7684\u597d\u5904\uff0c\u65b9\u4fbf\u6d4b\u8bd5\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320552\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : maocat <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u5df2\u7ecf\u5927\u5199\u4e86\u5c31\u662f\u516c\u5171\u8bbf\u95ee\u7684,\u6ca1\u5fc5\u8981\u518d\u6dfb\u52a0\u8fd9\u5197\u4f59\u7684\u65b9\u6cd5\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320554\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : maocat <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f53\u7136,\u5982\u679c\u4f60\u5728\u67e5\u627e\u4fee\u6539\u5c5e\u6027\u7684\u65f6\u5019\u60f3\u505a\u4e00\u4e9b\u5176\u4ed6\u7684\u4e8b\u513f,\u8fd9\u6837\u505a\u4e5f\u662f\u53ef\u4ee5\u7684,\u89c1\u4ec1\u89c1\u667a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320556\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : latteczy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8bf4\u7684\u7b2c\u4e00\u79cd\u65b9\u6cd5\u5b9e\u9645\u4e0a\u662f\u8d4b\u503c\u64cd\u4f5c\u5427\uff0c\u8d4b\u503c\u64cd\u4f5c\u8c03\u7528 Get \u65b9\u6cd5\uff0c\u8fd9\u4e5f\u592a\u5947\u602a\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320558\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shaopu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 set \u8ddf get \u90fd\u6765\u8d4b\u503c\uff0c\u611f\u89c9\u602a\u5427~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320559\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : heavyrainn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u4ee3\u7801\u98ce\u683c\u8ba9\u6211\u7acb\u523b\u60f3\u5230\u4e86 java\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320560\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : segama201901 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bed\u6cd5\u6709\u9519\u3002<\/p>\n<p>\u5927\u5199\u7684\u7ed3\u6784\u4f53\u4ee5\u53ca\u5927\u5199\u7684\u6210\u5458\u540d\u8868\u660e\u4e86\u6b64\u7ed3\u6784\u4f53\u4ee5\u53ca\u5176\u6210\u5458\u662f\u53ef\u4ee5\u5728 package \u5916\u8bbf\u95ee\u7684\u3002\u5982\u679c\u53ea\u662f\u8d4b\u503c\u7684\u8bdd\uff0c\u6ca1\u5fc5\u8981\u5c01\u88c5\u51fd\u6570\u3002<\/p>\n<p>\u5982\u679c\u5b9a\u4e49\u4e86\u76f8\u5173\u7684 interface\uff0c\u9700\u8981\u7ed9\u7ed3\u6784\u4f53\u5b9a\u4e49\u65b9\u6cd5\uff0c\u90a3\u4e48\u5b9a\u4e49\u65b9\u6cd5<br \/> func (a A) xxx() {}<br \/>\u6216\u8005<br \/> func (a *A) xxx() {}<br \/>\u7684\u5f62\u5f0f\u3002\u8fd9\u4e24\u79cd\u5f62\u5f0f\u6ca1\u6709\u533a\u522b\u3002<\/p>\n<p>\u5982\u679c\u9700\u8981\u4f7f\u7528\u51fd\u6570\uff0c\u5c06\u7ed3\u6784\u4f53\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u5230\u51fd\u6570\u5185\u8fdb\u884c\u64cd\u4f5c\uff0c\u90a3\u4e48\u5b9a\u4e49\u51fd\u6570<br \/> func (a *A) xxx() {}<br \/>\u4e0d\u5efa\u8bae\u4f7f\u7528<br \/> func (a A) xxx() {}<br \/>\u7684\u5f62\u5f0f\u3002\u56e0\u4e3a golang \u4e2d\uff0c\u7ed3\u6784\u4f53\u4f20\u53c2\u662f\u503c\u4f20\u9012\uff0c\u4f1a\u964d\u4f4e\u6548\u7387\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320561\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : segama201901 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @segama201901 \u66f4\u6b63\u4e00\u4e0b\uff0c\u65b9\u6cd5\u7684\u63a5\u6536\u8005\u662f\u6307\u9488\u8fd8\u662f\u503c\u7c7b\u578b\u8fd8\u662f\u6709\u533a\u522b\u7684\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003<br \/>https:\/\/www.jb51.net\/article\/56832.htm<br \/>https:\/\/www.cnblogs.com\/gardenofhu\/p\/9115284.html?utm_campaign=studygolang.com&amp;utm_medium=studygolang.com&amp;utm_source=studygolang.com                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3320562\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : hjahgdthab750 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3b\u8981\u662f\u6709\u4e9b\u5c5e\u6027\u7684\u503c\u8ba1\u7b97\u6bd4\u8f83\u590d\u6742\uff0c\u800c\u4e14\u4e0d\u65b9\u4fbf\u653e\u5728 New \u65b9\u6cd5\u4e2d @maocat @shaopu                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u95ee Go \u8bbe\u7f6e\u7ed3\u6784\u4f53\u5c5e\u6027\u7684\u6837\u5f0f &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/156190"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=156190"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/156190\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=156190"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=156190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}