{"id":200428,"date":"2020-11-14T15:23:32","date_gmt":"2020-11-14T07:23:32","guid":{"rendered":"http:\/\/4563.org\/?p=200428"},"modified":"2020-11-14T15:23:32","modified_gmt":"2020-11-14T07:23:32","slug":"golang-%e4%b8%ad%e7%9a%84%e5%80%bc%e4%bc%a0%e9%80%92%e5%92%8c%e6%8c%87%e9%92%88%e4%bc%a0%e9%80%92%e7%9a%84%e7%90%86%e8%a7%a3%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=200428","title":{"rendered":"golang \u4e2d\u7684\u503c\u4f20\u9012\u548c\u6307\u9488\u4f20\u9012\u7684\u7406\u89e3\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  golang \u4e2d\u7684\u503c\u4f20\u9012\u548c\u6307\u9488\u4f20\u9012\u7684\u7406\u89e3\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chinafengzhao <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4e0a\u4ee3\u7801<\/p>\n<pre><code> package main   import(     \"fmt\" )  \/\/ \u58f0\u660e\u4e00\u4e2a\u57fa\u4e8e int \u7684\u7c7b\u578b Integer type Integer int   \/\/ \u57fa\u4e8e\u6307\u9488\u7684\u4f20\u9012\uff08 Integer \u7c7b\u578b\u7684\u6307\u9488\u53d8\u91cf a \uff09 func (a* Integer) Add_pointer (b Integer) {     *a += b }  \/\/ \u57fa\u4e8e\u503c\u7684\u4f20\u9012\uff0c\u6309\u7406\uff0c\u7ecf\u8fc7\u8fd9\u6b21\u8c03\u7528\uff0c\u4e5f\u662f\u5bf9 a \u8fdb\u884c\u91cd\u65b0\u8d4b\u503c\uff0c\u4e3a\u4ec0\u4e48\u8c03\u7528\u4e4b\u540e\uff0c\u518d\u53bb\u6253\u5370\uff0c\u8fd8\u662f\u4ee5\u524d\u7684\u503c\uff1f func (a Integer) Add_value (b Integer) {     a += b }   func main() {     var a Integer = 1     var b Integer = 1     a.Add_pointer(2)     b.Add_value(2)     fmt.Println(\"a =\", a)     fmt.Println(\"b =\", b) }  \/\/ a=3 \/\/ b=1   <\/code><\/pre>\n<p>\u4e3a\u4ec0\u4e48\u4f1a\u6709\u8fd9\u4e2a\u8f93\u51fa\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>14<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4279240\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yatsun <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b66\u8fc7 c \u5417\uff0c\u5b50\u51fd\u6570\u91cc\u7684\u662f\u5f62\u53c2\uff0c\u662f\u989d\u5916\u5f00\u8f9f\u7684\u7a7a\u95f4\uff0c\u4e0d\u4f1a\u6539\u53d8\u539f\u672c\u7684\u503c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279241\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BoarBoar <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             C \u8bed\u8a00\u5b66\u8fc7\u5427\uff1f\u4e00\u6837\u7684<br \/>\u6307\u9488\u5c31\u662f\u53d8\u91cf a \u7684\u5185\u5b58\u5730\u5740\uff0c\u5728\u539f\u53d8\u91cf\u4e0a+2<br \/>\u5bf9\u4e8e b \u5b9e\u9645\u4e0a\u662f\u65b0\u521b\u5efa\u4e86\u4e00\u4e2a\u53d8\u91cf\uff0c\u6682\u4e14\u53eb\u505a b(1)\u5427\uff0cb(1)\u5b9e\u9645\u4e0a\u662f\u65b0\u7684\u4e00\u5757\u5185\u5b58\uff0c+2 \u540e\u5bf9\u539f\u53d8\u91cf\u6ca1\u5f71\u54cd                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279242\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : raaaaaar <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5fd8\u8bb0\u6307\u9488\uff0c\u5fd8\u8bb0\u503c\u4f20\u9012\uff0c\u5fd8\u8bb0\u4f20\u503c\u8fd9\u4e9b\u6982\u5ff5\u3002<br \/>\u8bb0\u4f4f\uff1a\u4e00\u4e2a\u662f\u64cd\u4f5c\u4e00\u5757\u5185\u5b58\uff0c\u4e00\u4e2a\u662f\u64cd\u4f5c\u4e24\u5757\u5185\u5b58\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279243\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shangyes <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u65b9\u6cd5\u662f\u51fd\u6570<br \/>&#8220;`golang<br \/>func Add_pointer(a* Integer, b Integer) {<br \/> *a += b<br \/>}<\/p>\n<p>func Add_value(a, b Integer) {<br \/> a += b<br \/>}<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279244\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yrj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @raaaaaar \u54c8\u54c8\uff0c\u8fd9\u4e48\u7406\u89e3\u633a\u597d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279245\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cholerae <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             go \u91cc\u9762\u53ea\u6709\u503c\u4f20\u9012\uff0c\u8bb0\u7740\u8fd9\u4e00\u70b9\u5c31\u884c\u4e86\u3002\u53ea\u4e0d\u8fc7\u6709\u65f6\u5019\u8fd9\u4e2a\u503c\u662f\u4e00\u4e2a\u6307\u9488\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279246\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cco <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u503c\u4f20\u9012\uff01\u6ca1\u6709\u522b\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279247\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xkeyideal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ece C \u8bed\u8a00\u7684\u89d2\u5ea6\u6765\u8bf4\uff0ca.Add_pointer(2) \u8fd9\u4e00\u884c\u4ee3\u7801\u90fd\u4e0d\u4f1a\u7f16\u8bd1\u901a\u8fc7\u7684\uff0c\u53e6\u5916\u5462\uff0c\u65e0\u8111\u6307\u9488\u4f1a\u6bd4\u8f83\u65b9\u4fbf\uff0c\u4f46\u6307\u9488\u5e76\u975e\u90fd\u662f\u6700\u4f18\u89e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279248\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hzfyjgw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             http:\/\/team.jiunile.com\/\/blog\/2020\/11\/go-copy-struct-or-pointer.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279249\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lance6716 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5176\u5b9e\u4e00\u76f4\u5bf9\u8fd9\u4e2a\u5f88\u8ff7\u60d1\uff0c\u5c24\u5176\u662f\u5230\u4e86\u542b\u6709\u6307\u9488\u7684\u7ed3\u6784\u4f53\u65f6\uff1a\u4f20\u6307\u9488\u7684\u5730\u5740\u5c31\u4e0d\u53eb\u4f20\u503c\u4e86\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279250\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joesonw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             4 \u662f\u6b63\u89e3. go \u4e0d\u662f OOP, \u6ca1\u6709 class, \u90fd\u53ea\u662f\u65b9\u6cd5\u800c\u5df2.<br \/>\u4f8b\u5982<\/p>\n<p>type S struct {}<\/p>\n<p>func (s *S) Say() {<br \/> println(&#8220;hello world&#8221;)<br \/>}<\/p>\n<p>func main() {<br \/> var s *S<br \/> s.Say()<br \/>}<\/p>\n<p>\u662f\u6b63\u5e38\u8fd0\u884c\u7684<br \/>https:\/\/play.golang.org\/p\/7pQ51IZ-4rB                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279251\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chor02 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u7406\u89e3\u70ba func (a* Integer)\u548c func (a Integer)\u4e2d\u7684 a*\u548c a \u4e5f\u662f\u4e00\u500b\u53c3\u6578                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279252\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ghjacky <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u662f go \u91cc\u8fb9\u7684 receiver\uff0c\u4e0d\u8fc7\u7c7b\u4f3c\u4e8e\u53c2\u6570\u4f20\u9012\uff0c\u90fd\u662f\u503c\u4f20\u9012\uff08\u62f7\u8d1d\u4e86\u4e00\u4efd\u6570\u636e\uff09\uff0c\u6307\u9488\u4f20\u9012\u4e5f\u662f\u503c\u4f20\u9012\uff0c\u53ea\u4e0d\u8fc7\u6307\u9488\u7c7b\u578b\u7684\u6570\u636e\u672c\u8eab\u5c31\u662f\u4e00\u5185\u5b58\u5730\u5740\uff0c\u6240\u4ee5\uff0c\u66f4\u6539\u6307\u9488\u6307\u5411\u5185\u5b58\u7a7a\u95f4\u7684\u503c\uff0c\u539f\u59cb\u503c\u4e5f\u4f1a\u6539\u53d8\u554a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4279253\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ScepterZ <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u53e5\u8bdd\u5c5e\u4e8e\u778e\u8bf4\u2026\u2026\u8fd9\u4e2a a \u662f\u590d\u5236\u6765\u7684\uff0c\u4e0d\u662f\u539f\u6765\u90a3\u4e2a<br \/>\u57fa\u4e8e\u503c\u7684\u4f20\u9012\uff0c\u6309\u7406\uff0c\u7ecf\u8fc7\u8fd9\u6b21\u8c03\u7528\uff0c\u4e5f\u662f\u5bf9 a \u8fdb\u884c\u91cd\u65b0\u8d4b\u503c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>golang \u4e2d\u7684\u503c\u4f20\u9012\u548c\u6307\u9488\u4f20\u9012&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\/200428"}],"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=200428"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/200428\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200428"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}