{"id":102542,"date":"2020-05-04T09:04:36","date_gmt":"2020-05-04T01:04:36","guid":{"rendered":"http:\/\/4563.org\/?p=102542"},"modified":"2020-05-04T09:04:36","modified_gmt":"2020-05-04T01:04:36","slug":"%e9%97%ae%e4%b8%aa-golang-%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=102542","title":{"rendered":"\u95ee\u4e2a Golang \u7684\u95ee\u9898~~"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u95ee\u4e2a Golang \u7684\u95ee\u9898~~               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hcyg <\/span>  <span><i><\/i> 51<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>aData := make([]GateData,len(add)) ArrayToStruct(add,aData)  <\/code><\/pre>\n<p>\u8fd9\u4e2a\u662f\u5f15\u7528\u7684\u5417\u3002\u3002\u4e0d\u7528\u63a5\u6536\u8fd4\u56de\u503c\uff0caData \u5c31\u53d8\u4e86<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"687537\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joyme <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u7ec4\u7c7b\u578b\u662f\u6bd4\u8f83\u7279\u6b8a\u7684\uff0c\u4f20\u53c2\u7684\u8bdd\u662f\u6570\u7ec4\u7684\u5185\u5b58\u9996\u5730\u5740\uff0c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687538\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qingsonghe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u5f15\u7528\uff0c\u4f46\u662f\u5982\u679c\u5207\u7247\u5728 ArrayToStruct \u51fd\u6570\u5185\u589e\u957f\uff0c\u90a3\u4e48 ArrayToStruct \u51fd\u6570\u8c03\u7528\u7ed3\u675f\u540e\uff0caData \u6307\u5411\u7684\u5207\u7247\u6570\u636e\u201c\u4e0d\u662f\u6700\u65b0\u7684\u201d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687539\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qingsonghe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f53\u7136\u4f20\u6307\u9488\u5f53\u7136\u662f\u6700\u4fdd\u9669\u7684\uff0c\u53ef\u4ee5\u9632\u6b62\u5207\u7247\u5728 ArrayToStruct \u51fd\u6570\u5185\u90e8\u589e\u957f\u7684\u95ee\u9898\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687540\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : di1012 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @joyme \u8fd9\u4e2a\u662f\u5207\u7247\u5427\uff0c\u5207\u7247\u4f20\u53c2\u7684\u786e\u662f\u5730\u5740\u4f20\u9012\u3002\u6570\u7ec4\u662f\u503c\u4f20\u9012                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687541\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : LancerEvo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             This is slice not array, and this is how slice looks:<\/p>\n<p>type slice struct { <br \/> Length int<br \/> Capacity int<br \/> ZerothElement *byte<br \/>}<\/p>\n<p>A slice contains the length, capacity and a pointer to the zeroth element of the array. When a slice is passed to a function, even though it&#8217;s passed by value, the pointer variable will refer to the same underlying array. Hence when a slice is passed to a function as parameter, changes made inside the function are visible outside the function too.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687542\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joyme <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @di1012 \u662f\u5207\u7247\u3002\u3002\u3002\u6211\u8bf4\u9519\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687543\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : hcyg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u8c22\u5404\u4f4d\u7684\u89e3\u7b54~~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687544\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cheneydog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5728 go \u91cc\u6570\u636e\u4f20\u9012\u5c31\u662f\u62f7\u8d1d\u5427\uff0c\u4f60\u7684\u4ee3\u7801\u5c31\u662f\u6570\u7ec4\u4f20\u9012\u5427\uff0c\u6240\u4ee5\u4ee3\u7801\u9519\u4e86\u5427\uff0c\u96be\u9053\u6211\u54ea\u91cc\u770b\u9519\u4e86?                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687545\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cheneydog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u786e\u5b9e\u662f\u5207\u7247\uff0c\u7cca\u6d82\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"687546\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : alexliux <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u63a8\u8350\u8fd9\u6837\u641e\u3002\u53e6\u5916\uff0cgo \u6ca1\u6709\u5f15\u7528\uff0c\u53ea\u6709\u503c\u4f20\u9012                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u4e2a Golang \u7684\u95ee\u9898~~ \u8cc7&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\/102542"}],"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=102542"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/102542\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102542"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}