{"id":10006403,"date":"2022-09-06T01:10:38","date_gmt":"2022-09-05T17:10:38","guid":{"rendered":"https:\/\/ityet.com\/?p=10006403"},"modified":"2022-09-06T01:10:38","modified_gmt":"2022-09-05T17:10:38","slug":"%e5%af%b9-go2-%e9%94%99%e8%af%af%e5%a4%84%e7%90%86%e6%8f%90%e6%a1%88%e7%9a%84%e6%89%b9%e5%88%a4","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006403","title":{"rendered":"\u5bf9 Go2 \u9519\u8bef\u5904\u7406\u63d0\u6848\u7684\u6279\u5224"},"content":{"rendered":"<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f\u714e\u9c7c\u3002<\/p>\n<p>\u4e00\u5e74\u534a\u524d\u5206\u4eab\u4e86\u300a<a href=\"https:\/\/link.segmentfault.com\/?enc=CcZ1OJoS7Hb6%2B7%2FMMvS4SA%3D%3D.EIXJpwmTxBPg7anQhAeyBp6c7L5HqP9S2jm3tlxqIByLPh3JdJ40bu9cP1mnejS82qepyGOOMiZajihppW61XQ%3D%3D\" rel=\"nofollow\">\u5148\u7779\u4e3a\u5feb\uff0cGo2 Error \u7684\u6323\u624e\u4e4b\u8def<\/a>\u300b\u7684\u6587\u7ae0\uff0c\u5185\u5bb9\u6d89\u53ca Go1 \u9519\u8bef\u5904\u7406\u7684\u95ee\u9898\u3001Go1.13 \u7684\u52a0\u5f3a\u3001Go2 \u7684\u65b0\u9519\u8bef\u5904\u7406\u63d0\u6848\u7684\u8be6\u89e3\u3002\u6709\u591a\u5c11\u5c0f\u4f19\u4f34\u8fd8\u8bb0\u5f97 Go2 \u7684\u65b0\u9519\u8bef\u63d0\u6848\u7684 \u201c\u7f8e\u597d\u201d \u672a\u6765\uff1f<\/p>\n<p>\u5f53\u65f6 Go2 \u7684\u65b0\u63d0\u6848\u4e5f\u906d\u53d7\u5230\u4e86\u4e0d\u5c11\u6279\u8bc4\uff0c@Liam Breck \u5728\u300aGolang, how dare you handle my checks!\u300b\u4e2d\u5bf9\u6b64\u8fdb\u884c\u4e86\u6279\u5224\uff0c\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u5b66\u4e60\u5427\uff01<\/p>\n<h2>\u590d\u4e60\u8bed\u6cd5<\/h2>\n<p>\u5728 2018 \u5e74 8 \u6708\uff0c\u5b98\u65b9\u6b63\u5f0f\u516c\u5e03\u4e86 <a href=\"https:\/\/link.segmentfault.com\/?enc=GMOG4sBoci5aqhYaEVwdjg%3D%3D.ieYigrp8MSfYgfHtdMrss6eQKtt6h%2BXdU99dmwY1hQUv2uE9KDZUllXvUoAcPwOZAf2rHNuhGfWFNuOONdE2XM2ENNaxwFRndZt4j4aGt9s%3D\" rel=\"nofollow\" title=\"Go 2 Draft Designs\">Go 2 Draft Designs<\/a>\uff0c\u5176\u4e2d\u5305\u542b\u6cdb\u578b\u548c\u9519\u8bef\u5904\u7406\u673a\u5236\u6539\u8fdb\u7684\u521d\u6b65\u8349\u6848\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000038666583\" alt=\"Go 2 Draft Designs\" title=\"Go 2 Draft Designs\" loading=\"lazy\"><\/p>\n<p>\u4e0b\u9762\u662f\u5173\u952e\u7684 Go2 \u9519\u8bef\u5904\u7406\u65b0\u8bed\u6cd5\u3002<\/p>\n<h3>\u9519\u8bef\u5904\u7406\uff08Error Handling\uff09<\/h3>\n<p>\u7b2c\u4e00\u4e2a\u8981\u89e3\u51b3\u7684\u95ee\u9898\u5c31\u662f\u5927\u91cf <code>if err != nil<\/code> \u7684\u95ee\u9898\uff0c\u9488\u5bf9\u6b64\u63d0\u51fa\u4e86 <a href=\"https:\/\/link.segmentfault.com\/?enc=v8hIfSV%2FzXqMUG%2F3et4qhg%3D%3D.wEkFP1WU0gLV8Bbazvd4e5oaonBTDLZuIo8%2B%2FwQtNFpyyXHULzYGG8hEJ0Dz6G%2FOCV88setgdVb0LqQH%2FfZOHQ0U94RTl89nlCguNBhgx6EqjRgnwYKJHkn9FVoHc2yi\" rel=\"nofollow\" title=\"Go2 error handling\">Go2 error handling<\/a> \u7684\u8349\u6848\u8bbe\u8ba1\u3002<\/p>\n<p>\u7b80\u5355\u4f8b\u5b50\uff1a<\/p>\n<pre><code>if err != nil {\n    return err\n}<\/code><\/pre>\n<p>\u4f18\u5316\u540e\u7684\u65b9\u6848\u5982\u4e0b\uff1a<\/p>\n<pre><code>func CopyFile(src, dst string) error {\n    handle err {\n        return fmt.Errorf(&quot;copy %s %s: %v&quot;, src, dst, err)\n    }\n\n    r := check os.Open(src)\n    defer r.Close()\n\n    w := check os.Create(dst)\n    handle err {\n        w.Close()\n        os.Remove(dst) \/\/ (only if a check fails)\n    }\n\n    check io.Copy(w, r)\n    check w.Close()\n    return nil\n}<\/code><\/pre>\n<p>\u4e3b\u51fd\u6570\uff1a<\/p>\n<pre><code>func main() {\n    handle err {\n        log.Fatal(err)\n    }\n\n    hex := check ioutil.ReadAll(os.Stdin)\n    data := check parseHexdump(string(hex))\n    os.Stdout.Write(data)\n}<\/code><\/pre>\n<p>\u8be5\u63d0\u6848\u5f15\u5165\u4e86\u4e24\u79cd\u65b0\u7684\u8bed\u6cd5\u5f62\u5f0f\uff0c\u9996\u5148\u662f <code>check<\/code> \u5173\u952e\u5b57\uff0c\u5176\u53ef\u4ee5\u9009\u4e2d\u4e00\u4e2a\u8868\u8fbe\u5f0f <code>check f(x, y, z)<\/code> \u6216 <code>check err<\/code>\uff0c\u5176\u5c06\u4f1a\u6807\u8bc6\u8fd9\u662f\u4e00\u4e2a\u663e\u5f0f\u7684\u9519\u8bef\u68c0\u67e5\u3002<\/p>\n<p>\u5176\u6b21\u5f15\u5165\u4e86 <code>handle<\/code> \u5173\u952e\u5b57\uff0c\u7528\u4e8e\u5b9a\u4e49\u9519\u8bef\u5904\u7406\u7a0b\u5e8f\u6d41\u8f6c\uff0c\u9010\u7ea7\u4e0a\u629b\uff0c\u4f9d\u6b64\u7c7b\u63a8\uff0c\u76f4\u5230\u5904\u7406\u7a0b\u5e8f\u6267\u884c <code>return<\/code> \u8bed\u53e5\uff0c\u624d\u6b63\u5f0f\u7ed3\u675f\u3002<\/p>\n<h3>\u9519\u8bef\u503c\u6253\u5370\uff08Error Printing\uff09<\/h3>\n<p>\u7b2c\u4e8c\u4e2a\u8981\u89e3\u51b3\u7684\u95ee\u9898\u662f\u9519\u8bef\u503c\uff08Error Values\uff09\u3001\u9519\u8bef\u68c0\u67e5\uff08Error Inspection\uff09\u7684\u95ee\u9898\uff0c\u5176\u5f15\u7533\u51fa\u9519\u8bef\u503c\u6253\u5370\uff08Error Printing\uff09\u7684\u95ee\u9898\uff0c\u4e5f\u53ef\u4ee5\u8ba4\u4e3a\u662f\u9519\u8bef\u683c\u5f0f\u5316\u7684\u4e0d\u4fbf\u5229\u3002<\/p>\n<p>\u5b98\u65b9\u9488\u5bf9\u6b64\u63d0\u51fa\u4e86\u63d0\u51fa\u4e86 <a href=\"https:\/\/link.segmentfault.com\/?enc=tEs0swbUoWzX15REkGJyag%3D%3D.tZltg%2F0dk5rUYhK3%2FNVqpXRgmTRQrxgXpyU3TF20tYjMDlkD6uKwVjbcZwteY5OhpkgxsoWC5wyNNqXbC6DQfkITAqEAkwdMvRfYf0ZV81tU2l%2FsksxWDwNnpioaDjes\" rel=\"nofollow\" title=\"Error Values\">Error Values<\/a> \u548c <a href=\"https:\/\/link.segmentfault.com\/?enc=hx%2BsU8Mcbxw0oOtGWBny%2FA%3D%3D.GRuT700BsPEBp8SmcEV84XLw8CNpz5Ri%2BOM9sHE7Tk%2FMSnG%2FFGeJ%2F37c5jKh%2FLHntonRLFMVsM7lmiV7zlEkAS1TQpuNaO35C9jEYCZB1Ro%2BB9j22Jmd3ZYJpmaYr6NZ\" rel=\"nofollow\" title=\"Error Printing\">Error Printing<\/a> \u7684\u8349\u6848\u8bbe\u8ba1\u3002<\/p>\n<p>\u7b80\u5355\u4f8b\u5b50\u5982\u4e0b\uff1a<\/p>\n<pre><code>if err != nil {\n    return fmt.Errorf(&quot;write users database: %v&quot;, err)\n}<\/code><\/pre>\n<p>\u4f18\u5316\u540e\u7684\u65b9\u6848\u5982\u4e0b\uff1a<\/p>\n<pre><code>package errors\n\ntype Wrapper interface {\n    Unwrap() error\n}\n\nfunc Is(err, target error) bool\nfunc As(type E)(err error) (e E, ok bool)<\/code><\/pre>\n<p>\u8be5\u63d0\u6848\u589e\u52a0\u4e86\u9519\u8bef\u94fe\u7684 Wrapping Error \u6982\u5ff5\uff0c\u5e76\u540c\u65f6\u589e\u52a0 <code>errors.Is<\/code> \u548c <code>errors.As<\/code> \u7684\u65b9\u6cd5\uff0c\u4e0e\u524d\u9762\u8bf4\u5230\u7684 Go1.13 \u7684\u6539\u8fdb\u4e00\u81f4\uff0c\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n<p>Go1.13 \u6ca1\u6709\u5b9e\u73b0 <code>%+v<\/code> \u8f93\u51fa\u8c03\u7528\u5806\u6808\u7684\u9700\u6c42\uff08\u6ca1\u6709\u8c03\u7528\u6808\uff0c\u6392\u67e5\u95ee\u9898\u4f1a\u5f88\u82e6\u607c\uff09\uff0c\u56e0\u4e3a\u6b64\u4e3e\u4f1a\u7834\u574f Go1 \u517c\u5bb9\u6027\u548c\u4ea7\u751f\u4e00\u4e9b\u6027\u80fd\u95ee\u9898\uff0c\u5927\u6982\u4f1a\u5728 Go2 \u52a0\u5165\u3002<\/p>\n<h2>\u5bf9\u63d0\u6848\u6279\u5224<\/h2>\n<h3>\u76ee\u6807\u8f83\u4e3a\u6a21\u7cca<\/h3>\n<p>\u5728 Go2 \u65b0\u9519\u8bef\u5904\u7406\u7684\u63d0\u6848\u548c\u8349\u6848\u4e2d\uff0c@Liam Breck \u8ba4\u4e3a\u5176\u6ca1\u6709\u53bb\u8ba8\u8bba\u6839\u672c\u7684\u9700\u6c42\u3002\u4ec5\u6709\u4e00\u4e2a\u7b80\u77ed\u7684\u76ee\u6807\u90e8\u5206\uff0c\u5982\u4e0b\u56db\u70b9\uff1a<\/p>\n<ul>\n<li>\u5360\u7528\u7a7a\u95f4\u5c0f\u7684\u9519\u8bef\u68c0\u67e5\u3002<\/li>\n<li>\u5bf9\u5f00\u53d1\u4eba\u5458\u53cb\u597d\u7684\u9519\u8bef\u5904\u7406\u3002<\/li>\n<li>\u663e\u5f0f\u68c0\u67e5\u548c\u5904\u7406\u9519\u8bef\u3002<\/li>\n<li>\u4fdd\u8bc1\u73b0\u6709 Go1 \u4ee3\u7801\u7684\u517c\u5bb9\u6027\u3002<\/li>\n<\/ul>\n<p>\u66f4\u4e5f\u6ca1\u6709\u63d0\u5230\u672a\u6765\u53ef\u80fd\u7684\u6269\u5c55\u6027\uff0c\u53ea\u662f\u7eaf\u7cb9\u7684\u6ee1\u8db3\u5f53\u4e0b\u7684\u8bc9\u6c42\u3002\u8fd9\u7c7b\u662f\u6a21\u7cca\u7684\uff0c\u5728\u6fc0\u53d1\u65b0\u7684\u8bbe\u8ba1\u601d\u8def\u4e0a\u6709\u5c40\u9650\u6027\u3002<\/p>\n<h3>\u65e0\u6cd5\u7edf\u4e00\u9519\u8bef\u5904\u7406<\/h3>\n<p>\u5728\u771f\u5b9e\u7684\u5e94\u7528\u4e2d\uff0c\u4e00\u4e2a\u51fd\u6570\u4f7f\u7528\u4e24\u79cd\u53ca\u4ee5\u4e0a\u7684\u91cd\u590d\u9519\u8bef\u5904\u7406\u65b9\u5f0f\u662f\u975e\u5e38\u5e38\u89c1\u7684\u3002<\/p>\n<p>\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"go\">\/\/ \u65b9\u5f0f 1\n{ debug.PrintStack(); log.Fatal(err) }\n\n\/\/ \u65b9\u5f0f 2\n{ log.Println(err) }\n\n\/\/ \u65b9\u5f0f 3\n{ if err == io.EOF { break } }\n\n\/\/ \u65b9\u5f0f 4\n{ conn.Write([]byte(&quot;oops: &quot; + err.Error())) } \/\/ network server<\/code><\/pre>\n<p>\u65b0\u63d0\u6848\u4e2d\uff0ccheck \u548c handle \u51fd\u6570\u5e76\u4e0d\u63d0\u4f9b\u591a\u79cd\u5904\u7406\u9519\u8bef\u7684\u9014\u5f84\u3002\u8fd9\u662f\u4e00\u4e2a\u660e\u663e\u7684\u9057\u6f0f\uff0c\u4e5f\u6ca1\u6cd5\u7edf\u4e00\u9519\u8bef\u5904\u7406\u673a\u5236\u3002<\/p>\n<p>\u5982\u6b64\u7684\u8bdd\uff0ccheck \u548c handle \u5c31\u5b8c\u5168\u662f\u53ea\u52a0\u4e86\u4e00\u79cd\u65b0\u7684\u65b9\u5f0f\uff0c\u8ba9\u539f\u672c\u7684\u9519\u8bef\u5904\u7406\u673a\u5236\u66f4\u52a0\u7684\u7e41\u6742\u3002<\/p>\n<h3>\u6df7\u7528 err != nil \u548c check<\/h3>\n<p>handle \u51fd\u6570\u662f\u540e\u8fdb\u5148\u51fa\u7684\u6a21\u5f0f\uff0c\u53ea\u80fd\u4ece\u4e00\u4e2a\u51fd\u6570\u4e2d\u8df3\u51fa\u3002\u4e5f\u5c31\u662f\u8bf4\u5b83\u4e0d\u80fd\u5f88\u53cb\u597d\u7684\u5904\u7406\u53ef\u6062\u590d\u7684\u9519\u8bef\u5185\u5bb9\u3002<\/p>\n<p>\u4f46\u5b9e\u9645\u4e0a\uff0c\u8bb8\u591a\u65b9\u6cd5\u8fd4\u56de\u9519\u8bef\u662f\u5f88\u5e38\u89c1\u7684\u3002\u56e0\u6b64\u6211\u4eec\u9700\u8981\u540c\u65f6\u4f7f\u7528 err!= nil \u548c check\uff0c\u663e\u5f97\u975e\u5e38\u7684\u7e41\u7410\u3002<\/p>\n<p>\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"go\">handle err { ... }\nv, err := f()\nif err != nil {\n   if isBad(err) {\n      check err\n   }\n   \/\/ recovery code\n}<\/code><\/pre>\n<p>\u53c8\u662f if err != nil\uff0c\u53c8\u662f handle\uff0c\u53c8\u662f check \u51fd\u6570\u3002<\/p>\n<h3>\u5d4c\u5957 check \u66f4\u590d\u6742<\/h3>\n<p>\u901a\u8fc7 check \u51fd\u6570\uff0c\u5bf9\u8fd4\u56de\u9519\u8bef\u7684\u51fd\u6570\u8c03\u7528\u8fdb\u884c\u5d4c\u5957\u8c03\u7528\uff0c\u5c06\u4f1a\u6a21\u7cca\u4e86\u64cd\u4f5c\u7684\u987a\u5e8f\u3002<\/p>\n<p>\u867d\u7136\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u9519\u8bef\u53d1\u751f\u65f6\u7684\u8c03\u7528\u987a\u5e8f\u5e94\u8be5\u662f\u6e05\u695a\u7684\uff0c\u4f46\u5728 check \u51fd\u6570\u4e0b\u4f1a\u663e\u5f97\u4e0d\u5982 if err != nil \u6e05\u6670\u3002<\/p>\n<p>\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"go\">check step4(check step1(), check step3(check step2())<\/code><\/pre>\n<p>\u53e6\u5916\u5d4c\u5957\u4ee3\u7801\u4f1a\u52a9\u957f\u4e0d\u53ef\u8bfb\u7684\u7ed3\u6784\uff1a<\/p>\n<pre><code class=\"go\">f1(v1, check f2(check f3(check f4(v4), v3), check f5(v5))<\/code><\/pre>\n<p>\u73b0\u5728\u56de\u987e\u4e00\u4e0b\uff0c\u8be5\u8bed\u8a00\u7981\u6b62\u3002<\/p>\n<pre><code class=\"go\">f(t ? a : b) \u548c f(a++)<\/code><\/pre>\n<p>\u662f\u4e0d\u662f\u663e\u5f97\u6709\u4e9b\u8bbd\u523a\u5462\uff1f<\/p>\n<h3>if err != nil \u592a\u597d\u7528<\/h3>\n<p>Go1 \u7684\u9519\u8bef\u5904\u7406\u7a0b\u5e8f\u592a\u53cb\u597d\u4e86\uff0c\u4e5f\u5c31\u662f\uff1a<\/p>\n<pre><code class=\"go\">if err != nil {\n    ...\n}<\/code><\/pre>\n<p>\u5176\u632b\u8d25\u4e86 &#8220;\u63d0\u9ad8\u5f00\u53d1\u4eba\u5458\u7f16\u5199\u9519\u8bef\u5904\u7406\u7a0b\u5e8f\u7684\u53ef\u80fd\u6027&#8221; \u7684\u76ee\u6807\uff0c\u5b83\u4f7f\u5f97\u5728\u6ca1\u6709\u4e0a\u4e0b\u6587\u4fe1\u606f\u7684\u60c5\u51b5\u4e0b\u8fd4\u56de\u9519\u8bef\u662f\u5f88\u5bb9\u6613\u7684\u3002<\/p>\n<p>\u6ce8\uff1a\u4e2a\u4eba\u611f\u89c9\uff0c\u8fd9\u4e00\u70b9\u65e2\u50cf\u9ed1\u53c8\u50cf\u7c89&#8230;\u539f\u4f5c\u8005\u53cd\u4e32\u9ed1\uff1f\u5f53\u7136\uff0c\u786e\u5b9e if err != nil \u5f88\u597d\u4e0a\u624b\u3002<\/p>\n<h3>\u590d\u6742\u7684\u9519\u8bef\u94fe<\/h3>\n<p>\u5bf9\u4e8e\u4e0b\u9762\u7684\u4f8b\u5b50\uff0c\u770b\u770b\u5b83\u7684\u611f\u89c9&#8230;<\/p>\n<p>\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"go\">func f() error {\n   handle err { return ... }           \/\/ finally this\n   if ... {\n      handle err { ... }               \/\/ not that\n      for ... {\n         handle err { ... }            \/\/ nor that\n         ...\n      }\n   }\n   handle err { ... }                  \/\/ secondly this\n   ...\n   if ... {\n      handle err { ... }               \/\/ not that\n      ...\n   } else {\n      handle err { ... }               \/\/ firstly this\n      check thisFails()                \/\/ trigger\n   }\n}<\/code><\/pre>\n<p>\u663e\u7136\uff0c\u8fd9\u6bb5\u4ee3\u7801\u662f \u201c\u96be\u4ee5\u6349\u6478\u201d \u7684\uff0c\u6211\u4eec\u5fc5\u987b\u7528\u773c\u775b\u89e3\u6790\u6574\u4e2a\u51fd\u6570\uff0c\u7406\u89e3\u6574\u4e2a\u9519\u8bef\u5904\u7406\u7684\u6d41\u7a0b\u548c\u987a\u5e8f\u3002<\/p>\n<p>\u5c06\u4f1a\u52a0\u5927\u6211\u4eec\u5bf9\u7a0b\u5e8f\u7684\u8ba4\u77e5\u8d1f\u62c5\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u5bf9 Go2 \u9519\u8bef\u5904\u7406\u7684\u8bbe\u8ba1\u8349\u6848\u7684\u590d\u4e60\uff0c\u6211\u4eec\u4e86\u89e3\u5230\u4e86 check \u548c handle \u51fd\u6570\u7684\u7528\u6cd5\u548c\u601d\u8def\u3002\u518d\u9488\u5bf9\u65b0\u7684\u8bed\u6cd5\uff0c\u53c8\u5bf9\u53ef\u80fd\u53d1\u751f\u7684\u65b0\u95ee\u9898\u8fdb\u884c\u4e86 \u201c\u6279\u5224\u201d\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u65b0\u7684\u8bed\u6cd5\uff0c\u5728\u5f0a\u7aef\u4e0a\u4f1a\u589e\u52a0\u65e2\u6709\u7684\u4ee3\u7801\u590d\u6742\u5ea6\u548c\u53ef\u8bfb\u6027\uff0c\u53ef\u4ee5\u5f15\u53d1\u5404\u79cd\u5947\u602a\u7684\u5d4c\u5957\uff0c\u8fd8\u4f1a\u4e0e if err != nil \u4ea7\u751f\u91cd\u590d\uff0c\u53d8\u6210\u4e86\u4e00\u79cd\u65b0\u7684\u5904\u7406\u65b9\u5f0f\uff08\u591a\u4e86\u4e00\u79cd\uff09\u3002<\/p>\n<p>\u662f\u5426\u4f1a\u8fd8\u4e0d\u5982 if err != nil \u90a3\u4e48\u7684\u7eaf\u7cb9\uff1f<\/p>\n<h3>Go \u56fe\u4e66\u7cfb\u5217<\/h3>\n<ul>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=qVoD960Jg1wvLnq3xF4NFw%3D%3D.iy3JH1HeqcLVsuV%2BQRV%2Bjoh6nmSw8B4A1llfYa1CUfFq2nMdLWoIMVApY%2BDNa8LB\" rel=\"nofollow\">Go \u8bed\u8a00\u5165\u95e8\u7cfb\u5217\uff1a\u521d\u63a2 Go \u9879\u76ee\u5b9e\u6218<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=wT50dpq7RANRHVEcm22%2Fww%3D%3D.Loh%2FYonFDWxQCICiAhcD05Pu3i9HA7eoFNdLOj%2BadG8%3D\" rel=\"nofollow\">Go \u8bed\u8a00\u7f16\u7a0b\u4e4b\u65c5\uff1a\u6df1\u5165\u7528 Go \u505a\u9879\u76ee<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=XgHan3ZrfI1Dnawhj4SJHA%3D%3D.11op2JTgx8UKV24DPzVYohN57B0ek78Z3hDg%2BxOmT5o%3D\" rel=\"nofollow\">Go \u8bed\u8a00\u8bbe\u8ba1\u54f2\u5b66\uff1a\u4e86\u89e3 Go \u7684\u4e3a\u4ec0\u4e48\u548c\u8bbe\u8ba1\u601d\u8003<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=W%2BbpDQ2E2NZdGhsySfQhqw%3D%3D.648caJzWvD5TitouWF7PDhY0jP1Ws9e07HMMkBH9oUo%3D\" rel=\"nofollow\">Go \u8bed\u8a00\u8fdb\u9636\u4e4b\u65c5\uff1a\u8fdb\u4e00\u6b65\u6df1\u5165 Go \u6e90\u7801<\/a><\/li>\n<\/ul>\n<h3>\u63a8\u8350\u9605\u8bfb<\/h3>\n<ul>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=IRvqm5BEkUs0ukO1OQgPZQ%3D%3D.IFht8s1MHM5qdQbPr9qhw%2Fq6JoE5ZwT87AUPwlLECusRKLXNwcBAqzRPnVGRM5MeF0rbeKp%2FYkV0K0Sz943l1A%3D%3D\" rel=\"nofollow\">goto \u8bed\u53e5\u8ba9 Go \u4ee3\u7801\u53d8\u6210\u610f\u5927\u5229\u9762\u6761\uff1f<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=pMzveTYpJOVUWQ%2F6xZHzJA%3D%3D.R7q9MwK8geDprLBcuT2V4t0hezVUOyGNftqK7CkLVq5%2FQNCp3U1TJsdlePj9jTOYqmilQNJmDPvxzHI3tic1JQ%3D%3D\" rel=\"nofollow\">Go \u53ea\u4f1a if err != nil\uff1f\u8fd9\u662f\u4e0d\u5bf9\u7684\uff0c\u5206\u4eab\u8fd9\u4e9b\u4f18\u96c5\u7684\u5904\u7406\u59ff\u52bf\u7ed9\u4f60\uff01<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042436554\">https:\/\/segmentfault.com\/a\/1190000042436554<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u5bb6\u597d\uff0c\u6211\u662f\u714e\u9c7c\u3002 \u4e00\u5e74\u534a\u524d\u5206\u4eab\u4e86\u300a\u5148\u7779\u4e3a\u5feb\uff0cGo2 Error \u7684\u6323\u624e\u4e4b\u8def\u300b\u7684\u6587\u7ae0\uff0c\u5185\u5bb9\u6d89\u53ca Go1 \u9519\u8bef\u5904 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006403","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006403"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006403\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}