{"id":187,"date":"2016-07-02T02:56:32","date_gmt":"2016-07-02T02:56:32","guid":{"rendered":""},"modified":"2016-07-02T02:56:32","modified_gmt":"2016-07-02T02:56:32","slug":"","status":"publish","type":"post","link":"http:\/\/weizn.net\/?p=187","title":{"rendered":"Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362"},"content":{"rendered":"<p><span style=\"font-size:14px;\">package main<\/span><\/p>\n<p><span style=\"font-size:14px;\"> import(<\/span><br \/>\n<span style=\"font-size:14px;\"> &#8220;fmt&#8221;<\/span><br \/>\n<span style=\"font-size:14px;\"> )<\/span><\/p>\n<p><span style=\"font-size:14px;\"> type Integer int<\/span><br \/>\n<span style=\"font-size:14px;\"> \/\/\u7ed9\u5bf9\u8c61\u6dfb\u52a0\u64cd\u4f5c\u51fd\u6570<\/span><br \/>\n<span style=\"font-size:14px;\"> func (self Integer)less(a Integer) (Integer){<\/span><br \/>\n<span style=\"font-size:14px;\"> if self&lt;a{<\/span><br \/>\n<span style=\"font-size:14px;\"> return self<\/span><br \/>\n<span style=\"font-size:14px;\"> }<\/span><\/p>\n<p><span style=\"font-size:14px;\"> return a<\/span><br \/>\n<span style=\"font-size:14px;\"> }<\/span><\/p>\n<p><span style=\"font-size:14px;\"> func (self *Integer)add(a Integer) (Integer) {<\/span><br \/>\n<span style=\"font-size:14px;\"> *self+=a<\/span><\/p>\n<p><span style=\"font-size:14px;\"> return *self<\/span><br \/>\n<span style=\"font-size:14px;\"> }<\/span><\/p>\n<p><span style=\"font-size:14px;\"> func pointer_test(i *Integer){<\/span><br \/>\n<span style=\"font-size:14px;\"> *i+=1<\/span><br \/>\n<span style=\"font-size:14px;\"> }<\/span><\/p>\n<p><span style=\"font-size:14px;\"> func main() {<\/span><br \/>\n<span style=\"font-size:14px;\"> var i Integer = 1<\/span><\/p>\n<p><span style=\"font-size:14px;\"> min := i.less(10)<\/span><br \/>\n<span style=\"font-size:14px;\"> fmt.Println(min)<\/span><\/p>\n<p><span style=\"font-size:14px;\"> (&amp;i).add(1)<\/span><br \/>\n<span style=\"font-size:14px;\"> fmt.Println(i)<\/span><\/p>\n<p><span style=\"font-size:14px;\"> i.add(1)<\/span><br \/>\n<span style=\"font-size:14px;\"> fmt.Println(i)<\/span><\/p>\n<p><span style=\"font-size:14px;\"> pointer_test(&amp;i)<\/span><br \/>\n<span style=\"font-size:14px;\"> fmt.Println(i)<\/span><\/p>\n<p><span style=\"font-size:14px;\"> \/\/pointer_test(i)<\/span><br \/>\n<span style=\"font-size:14px;\"> \/\/fmt.Println(i)<\/span><\/p>\n<p>\n\t<span style=\"font-size:14px;\">}<\/span>\n<\/p>\n<p>\n\t\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\">&nbsp; &nbsp; \u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86Integer\u5bf9\u8c61\uff0c\u5176\u4e2d\u6709\u4e2a\u64cd\u4f5c\u51fd\u6570\u4e3aadd\uff0c\u5b83\u663e\u5f0f\u83b7\u53d6\u4e86\u81ea\u5df1\u5bf9\u8c61\u5b9e\u4f8b\u7684\u6307\u9488\uff0c\u6240\u4ee5\u5728\u8c03\u7528\u6b64\u5bf9\u8c61\u7684add\u51fd\u6570\u65f6\uff0c\u6211\u4eec\u91c7\u7528\u4e86<\/span><span style=\"white-space:normal;font-size:14px;\">(&amp;i).add(1)\u65b9\u5f0f\uff0c\u4f46\u662f\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<\/span><span style=\"white-space:normal;font-size:14px;\">i.add(1)\u65b9\u5f0f<\/span><span style=\"font-size:14px;\">\u4f20\u5165\u672c\u5b9e\u4f8b\u7684\u6307\u9488\uff0c\u56e0\u4e3aGo\u4f1a\u81ea\u52a8\u4f20\u5165\u5b9e\u4f8b\u7684\u6307\u9488\u3002\u4f46\u662f\u8fd9\u5e76\u4e0d\u4ee3\u8868Go\u4f1a\u5c06\u6240\u6709\u5b9e\u4f8b\u90fd\u81ea\u52a8\u8f6c\u6362\u4e3a\u6307\u9488\u7c7b\u578b\u8fdb\u884c\u4f20\u53c2\uff0c\u6bd4\u5982\u5728\u8c03\u7528pointer_test()\u65f6\uff0c\u4f20\u9012&amp;i\u662f\u5bf9\u7684\uff0c\u4f46\u662f\u4f20\u9012i\u5c31\u4f1a\u62a5\u9519\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>package main<\/p>\n<p>import(<br \/>\n&#8220;fmt&#8221;<br \/>\n)<\/p>\n<p>type Integer int<br \/>\n\/\/\u7ed9\u5bf9\u8c61\u6dfb\u52a0\u64cd\u4f5c\u51fd\u6570<br \/>\nfunc (self Integer)less(a Integer) (Integer){<br \/>\nif self&lt;a{<br \/>\nreturn self<br \/>\n}<\/p>\n<p>return a<br \/>\n}<\/p>\n<p>func (self *Integer)add(a Integer) (Integer&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[336],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362 - Wayne&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/weizn.net\/?p=187\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362 - Wayne&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"package main import( &quot;fmt&quot; ) type Integer int \/\/\u7ed9\u5bf9\u8c61\u6dfb\u52a0\u64cd\u4f5c\u51fd\u6570 func (self Integer)less(a Integer) (Integer){ if self&lt;a{ return self } return a } func (self *Integer)add(a Integer) (Integer...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/weizn.net\/?p=187\" \/>\n<meta property=\"og:site_name\" content=\"Wayne&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-02T02:56:32+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"zinan\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/weizn.net\/#website\",\"url\":\"http:\/\/weizn.net\/\",\"name\":\"Wayne&#039;s Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/weizn.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/weizn.net\/?p=187#webpage\",\"url\":\"http:\/\/weizn.net\/?p=187\",\"name\":\"Go\\u4e2d\\u7684\\u6307\\u9488\\u8f6c\\u6362 - Wayne&#039;s Blog\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/#website\"},\"datePublished\":\"2016-07-02T02:56:32+00:00\",\"dateModified\":\"2016-07-02T02:56:32+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/weizn.net\/?p=187#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/weizn.net\/?p=187\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/weizn.net\/?p=187#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\\u9996\\u9875\",\"item\":\"http:\/\/weizn.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go\\u4e2d\\u7684\\u6307\\u9488\\u8f6c\\u6362\"}]},{\"@type\":\"Article\",\"@id\":\"http:\/\/weizn.net\/?p=187#article\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/?p=187#webpage\"},\"author\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"headline\":\"Go\\u4e2d\\u7684\\u6307\\u9488\\u8f6c\\u6362\",\"datePublished\":\"2016-07-02T02:56:32+00:00\",\"dateModified\":\"2016-07-02T02:56:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/weizn.net\/?p=187#webpage\"},\"wordCount\":92,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"articleSection\":[\"Go\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/weizn.net\/?p=187#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\",\"name\":\"zinan\",\"logo\":{\"@id\":\"http:\/\/weizn.net\/#personlogo\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362 - Wayne&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/weizn.net\/?p=187","og_locale":"zh_CN","og_type":"article","og_title":"Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362 - Wayne&#039;s Blog","og_description":"package main import( \"fmt\" ) type Integer int \/\/\u7ed9\u5bf9\u8c61\u6dfb\u52a0\u64cd\u4f5c\u51fd\u6570 func (self Integer)less(a Integer) (Integer){ if self&lt;a{ return self } return a } func (self *Integer)add(a Integer) (Integer...","og_url":"http:\/\/weizn.net\/?p=187","og_site_name":"Wayne&#039;s Blog","article_published_time":"2016-07-02T02:56:32+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"zinan"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/weizn.net\/#website","url":"http:\/\/weizn.net\/","name":"Wayne&#039;s Blog","description":"","publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/weizn.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/weizn.net\/?p=187#webpage","url":"http:\/\/weizn.net\/?p=187","name":"Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362 - Wayne&#039;s Blog","isPartOf":{"@id":"http:\/\/weizn.net\/#website"},"datePublished":"2016-07-02T02:56:32+00:00","dateModified":"2016-07-02T02:56:32+00:00","breadcrumb":{"@id":"http:\/\/weizn.net\/?p=187#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/weizn.net\/?p=187"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/weizn.net\/?p=187#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/weizn.net\/"},{"@type":"ListItem","position":2,"name":"Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362"}]},{"@type":"Article","@id":"http:\/\/weizn.net\/?p=187#article","isPartOf":{"@id":"http:\/\/weizn.net\/?p=187#webpage"},"author":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"headline":"Go\u4e2d\u7684\u6307\u9488\u8f6c\u6362","datePublished":"2016-07-02T02:56:32+00:00","dateModified":"2016-07-02T02:56:32+00:00","mainEntityOfPage":{"@id":"http:\/\/weizn.net\/?p=187#webpage"},"wordCount":92,"commentCount":0,"publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"articleSection":["Go"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/weizn.net\/?p=187#respond"]}]},{"@type":["Person","Organization"],"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264","name":"zinan","logo":{"@id":"http:\/\/weizn.net\/#personlogo"}}]}},"_links":{"self":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187"}],"version-history":[{"count":0,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions"}],"wp:attachment":[{"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}