{"id":313250,"date":"2021-01-18T05:36:22","date_gmt":"2021-01-17T21:36:22","guid":{"rendered":"http:\/\/4563.org\/?p=313250"},"modified":"2021-01-18T05:36:22","modified_gmt":"2021-01-17T21:36:22","slug":"%e6%b1%82%e5%a4%a7%e4%bd%ac%e8%a7%a3%e7%ad%94%e4%b8%80%e4%b8%8b-go-%e7%9b%b8%e5%85%b3%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=313250","title":{"rendered":"\u6c42\u5927\u4f6c\u89e3\u7b54\u4e00\u4e0b Go \u76f8\u5173\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u5927\u4f6c\u89e3\u7b54\u4e00\u4e0b Go \u76f8\u5173\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xbh1794970183564 <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>LZ \u662f Java \u8f6c go\uff0c\u76ee\u524d\u5bf9 go \u7684\u6307\u9488\u4e0d\u662f\u5f88\u7406\u89e3\uff0c\u5f88\u591a\u65f6\u5019\u4e0d\u660e\u767d\u4e3a\u4ec0\u4e48\u8981\u7528\u6307\u9488\uff0c\u6bd4\u5982\u4e0b\u9762\u7684\u8bed\u53e5<\/p>\n<p>var feeds []*Feed err = json.NewDecoder(file).Decode(&amp;feeds) return feeds, err<\/p>\n<p>\u8fd9\u91cc\u6ca1\u770b\u660e\u767d\u4e3a\u4ec0\u4e48\u8981\u7528*Feed, \u76f4\u63a5 Feed \u4e3a\u4ec0\u4e48\u4e0d\u884c\u5462\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>11<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5161379\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xbh1794970183564 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6392\u7248\u6b6a\u4e86\u3002\u3002\u3002\u5927\u4f6c\u8c05\u89e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161380\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cmostuor <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             var feeds []<br \/>*Feed, err = json.NewDecoder(file).Decode(&amp;feeds) <br \/>return feeds, err<\/p>\n<p>\u81f3\u4e8e\u4e3a\u5565\u8981\u52a0* \u6709 c \u6216 c++\u8bed\u8a00\u7ecf\u9a8c\u7684\u5c31\u77e5\u9053\u8fd9\u662f\u6307\u9488\u8fd0\u7b97\u7b26, go \u8bed\u8a00\u662f c \u8bed\u8a00\u5f00\u53d1\u7684\u5927\u4f6c\u9886\u5bfc\u56e2\u961f\u5f00\u53d1\u7684, \u4e3a\u7684\u662f\u89e3\u51b3\u5e76\u53d1\u95ee\u9898                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161381\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : darksword21 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @cmostuor \u5efa\u8bae\u91cd\u65b0\u5ba1\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161382\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : darksword21 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u89c9\u5f97\u76f4\u63a5\u7528 Feed \u4e5f\u53ef\u4ee5\uff0c\u9664\u975e\u4f60\u6709\u9700\u8981\u5224\u65ad != nil \u7684\u9700\u6c42\uff0c\u5f53\u7136\u5177\u4f53\u7684\u6211\u4e86\u89e3\u4e5f\u4e0d\u6df1\uff0c\u521a\u6bd5\u4e1a\u7684\u55b3\u55b3\uff0c<br \/>\u6700\u8fd1\u6b63\u51c6\u5907\u4e86\u89e3\u4e0b\u603b\u7ed3\u4e00\u7bc7\u535a\u5ba2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161383\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : darksword21 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6027\u80fd\u4e0a\u6765\u8bf4<\/p>\n<p>https:\/\/stackoverflow.com\/questions\/27622083\/slices-of-structs-vs-slices-of-pointers-to-structs                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161384\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xbh1794970183564 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @darksword21 \u4e3b\u8981\u521a\u5f00\u59cb\u5b66\uff0c\u770b\u4e86\u51e0\u4e2a\u4ee3\u7801\uff0c\u611f\u89c9\u5f88\u591a\u5730\u65b9\u90fd\u7528\u4e86\u6307\u9488\uff0c\u4f46\u662f\u53c8\u8bf4\u4e0d\u4e0a\u6765\u4e3a\u4ec0\u4e48\u8981\u7528\uff0c\u5c31\u5f88\u96be\u53d7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161385\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : carlclone <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u7684\u7406\u89e3\u662f go \u91cc\u6ca1\u6709\u5f15\u7528\u4f20\u503c\uff0c\u90fd\u662f\u62f7\u8d1d\u7684\uff0c\u62f7\u8d1d\u6307\u9488\u6bd4\u62f7\u8d1d\u7ed3\u6784\u4f53\u7684\u5f00\u9500\u5c0f\uff1f\u4e0d\u77e5\u9053\u5bf9\u4e0d\u5bf9\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161386\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : xbh1794970183564 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @carlclone \u597d\u50cf\u6709\u9053\u7406                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161387\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : seth19960929 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5176\u5b9e\u9053\u7406\u5f88\u7b80\u5355\u5440. \u4efb\u4f55\u8bed\u8a00\u90fd\u662f\u8fd9\u6837.<br \/>\u4f60\u628a\u4e00\u4e2a\u53d8\u91cf\u4f20\u8fdb\u51fd\u6570, \u90a3\u4e48\u90fd\u662f\u503c\u4f20\u9012, \u65e0\u6cd5\u4ece\u51fd\u6570\u5185\u90e8\u76f4\u63a5\u6539\u53d8\u51fd\u6570\u5916\u7684\u8fd9\u4e2a\u53d8\u91cf<br \/>****<br \/>\u5f53\u4f60\u4f20\u9012\u4e00\u4e2a\u5f15\u7528\u6216\u8005\u6307\u9488, \u90a3 Decode \u51fd\u6570\u5c31\u53ef\u4ee5\u5728\u5185\u90e8\u5bf9\u4f60\u8fd9\u4e2a\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u64cd\u4f5c.<\/p>\n<p>\u4f60\u8bd5\u8bd5\u4f20\u9012:(\u6ce8\u610f \u661f\u661f\u7684\u4f4d\u7f6e)<br \/>var feeds *[]Feed = new([]Feed)<br \/>\u90a3\u4f60\u5c31\u4e0d\u7528\u4f20\u9012\u5f15\u7528\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161388\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lysS <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             func (dec *Decoder) Decode(v interface{}) error<br \/>\u6ca1\u641e\u9519\u5427\uff1f\u53ea\u7528\u4e00\u4e2a\u8fd4\u56de\u503c err \u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5161389\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BeautifulSoap <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5148\u4e0d\u8bba\u8fd9\u4e2a\u4ee3\u7801\u3002\u3002\u3002\u3002<\/p>\n<p>\u7528\u6307\u9488\u4e3b\u8981\u662f\u4e00\u822c\u8ba4\u4e3a\uff0c\u4f20\u6307\u9488\u6bd4\u4f20\u503c\u7684\u6027\u80fd\u635f\u8017\u5c0f\uff0c\u800c\u4e14\u4f20\u503c\u8fd8\u6d89\u53ca\u5230\u6307\u62f7\u8d1d\u7684\u95ee\u9898<\/p>\n<p>\u4f46\u662f\u5728 go \u91cc\u9762\u8fd9\u4e2a\u95ee\u9898\u4e5f\u4e0d\u662f\u7edd\u5bf9\u7684\uff0c\u56e0\u4e3a\u4f60\u4f20\u6307\u9488\u7684\u8bdd\u8fd8\u4f1a\u9047\u5230\u9003\u9038\u95ee\u9898\uff0c\u6709\u65f6\u5019\u4f20\u6307\u9488\u6027\u80fd\u8fd8\u4e0d\u5982\u76f4\u63a5\u503c\u62f7\u8d1d\u597d<\/p>\n<p>\u6240\u4ee5\u5bf9\u4e8e go \u7ecf\u9a8c\u6027\u6765\u8bf4\uff0c\u5bf9\u4e8e\u5c0f\u7684 struct \u9009\u62e9\u503c\u62f7\u8d1d\u6027\u80fd\u8f83\u597d\uff0c\u5bf9\u4e8e\u5927\u7684 struct \u4f20\u6307\u9488\u6027\u80fd\u4f1a\u597d<\/p>\n<p>\u4f46\u662f\u5bf9\u4e8e\u4ec0\u4e48\u4e8b\u5c0f struct\uff0c\u4ec0\u4e48\u4e8b\u5927 struct\uff0c\u5c31\u6ca1\u4ec0\u4e48\u7edf\u4e00\u6807\u51c6\u4e86\u3002\u3002\u3002\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u5927\u4f6c\u89e3\u7b54\u4e00\u4e0b Go \u76f8\u5173\u7684\u95ee\u9898 &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\/313250"}],"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=313250"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/313250\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313250"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}