{"id":808,"date":"2021-03-23T00:36:52","date_gmt":"2021-03-22T16:36:52","guid":{"rendered":"https:\/\/www.myway5.com\/?p=808"},"modified":"2023-07-05T10:01:24","modified_gmt":"2023-07-05T02:01:24","slug":"go-panic","status":"publish","type":"post","link":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/","title":{"rendered":"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f"},"content":{"rendered":"<h2>\u6982\u8ff0<\/h2>\n<p>\u4f5c\u4e3a\u4e00\u4e2a\u7ecf\u5e38\u5199 go \u7684\u7a0b\u5e8f\u5458\uff0c\u80af\u5b9a\u65f6\u4e0d\u65f6\u4f1a\u770b\u5230 go \u7684 panic \u4fe1\u606f\u3002\u4e00\u822c\u6211\u4eec\u90fd\u53ef\u4ee5\u6839\u636e\u4fe1\u606f\u8f7b\u677e\u5b9a\u4f4d\u5230\u51fa\u9519\u7684\u4ee3\u7801\u884c\u6570\uff0c\u4f46\u4e5f\u56e0\u4e3a\u8fd9\u4e2a\u539f\u56e0\uff0c\u5f80\u5f80\u5ffd\u89c6\u4e86\u5176\u4ed6\u7684\u4e00\u4e9b\u4fe1\u606f\u3002\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u6765\u5206\u6790\uff0cgo \u7a0b\u5e8f panic \u65f6\u8f93\u51fa\u7684\u9519\u8bef\u4fe1\u606f\u5230\u5e95\u5982\u4f55\u7406\u89e3\uff1f<\/p>\n<h2>\u4f8b\u5b50\u5206\u6790<\/h2>\n<p>\u4e0b\u9762\u6211\u4eec\u5148\u7528\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u8bf4\u660e\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">package main\n\nimport (\n    \"fmt\"\n)\n\ntype Person struct {\n    name string\n    age  int\n}\n\nfunc (person *Person) say(words []string) (ret int) {\n    for i := range words {\n        ret++\n        fmt.Printf(\"%s say: %s\", person.name, words[i])\n    }\n    return\n}\n\nfunc main() {\n    var person *Person\n    words := []string{\n        \"hello\",\n        \"world\",\n    }\n    person.say(words)\n}\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u4e00\u8fd0\u884c\u5c31\u4f1a panic\uff0c\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash line-numbers\">panic: runtime error: invalid memory address or nil pointer dereference\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x493373]\n\ngoroutine 1 [running]:\nmain.(*Person).say(0x0, 0xc000072f58, 0x2, 0x2, 0x0)\n    \/home\/jiangpengfei.jiangpf\/projects\/panic_demo\/main.go:15 +0x43\nmain.main()\n    \/home\/jiangpengfei.jiangpf\/projects\/panic_demo\/main.go:26 +0x7d\n<\/code><\/pre>\n<ol>\n<li><code>panic: runtime error: invalid memory address or nil pointer dereference<\/code>\u3002\u8fd9\u53e5\u8bdd\u8868\u9762\u4e86\u8fd9\u662f\u4e00\u4e2a panic \u5f02\u5e38\uff0c\u5e76\u4e14\u53ef\u80fd\u539f\u56e0\u662f\u65e0\u6548\u7684\u5185\u5b58\u5730\u5740\u6216\u7a7a\u6307\u9488\u7684\u89e3\u5f15\u7528<\/p>\n<\/li>\n<li>\n<p><code>[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x493373]<\/code>\u3002<code>SIGSEGV<\/code> \u5f53\u4e00\u4e2a\u8fdb\u7a0b\u6267\u884c\u4e86\u4e00\u4e2a\u65e0\u6548\u7684\u5185\u5b58\u5f15\u7528\uff0c\u6216\u53d1\u751f\u6bb5\u9519\u8bef\u65f6\u53d1\u9001\u7ed9\u5b83\u7684\u4fe1\u53f7\u3002<code>0x1<\/code>\u5bf9\u5e94\u7684\u662f<code>SEGV_MAPERR<\/code>\uff0c\u4e5f\u5c31\u662f\u6307<code>\u5730\u5740\u672a\u627e\u5230\u5bf9\u8c61<\/code>\u3002<code>addr<\/code>\u662f<code>0x8<\/code>\uff0c\u8fd9\u5e76\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684\u5185\u5b58\u5730\u5740\u3002<code>pc<\/code>\u662f\u7a0b\u5e8f\u8ba1\u6570\u5668\uff0c\u7528\u6765\u6307\u5411\u4e0b\u4e00\u6761\u6307\u4ee4\u5b58\u653e\u7684\u4f4d\u7f6e\u3002<\/p>\n<\/li>\n<li>\n<p><code>goroutine 1 [running]<\/code>\u3002<code>1<\/code>\u662f goroutine \u7684 ID\u3002<code>running<\/code>\u4ee3\u8868\u8be5\u534f\u7a0b\u5728\u53d1\u751f\u5f02\u5e38\u65f6\u7684\u72b6\u6001\u3002<\/p>\n<\/li>\n<li>\n<p><code>main.(*Person).say(0x0, 0xc000072f58, 0x2, 0x2, 0x0)<\/code>\u3002<code>main<\/code>\u662f package\uff0c<code>(*Person)<\/code>\u662f\u7c7b\u578b\uff0c<code>say<\/code>\u662f\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0csay \u7684\u8c03\u7528\u5171\u6709 5 \u7684\u53c2\u6570\u3002\u4f46\u4ee3\u7801\u4e2d\uff0csay \u7684\u8c03\u7528\u5176\u5b9e\u53ea\u6709 1 \u4e2a\u53c2\u6570\u3002\u5176\u5b9e\u5462\uff0c<\/p>\n<ol>\n<li>\u7b2c 1 \u53c2\u6570\u662f receiver\uff0c\u8fd9\u91cc\u5c31\u662f <code>*Person<\/code>\u3002\u503c\u4e3a <code>0x0<\/code>\u8bf4\u660e\u5b83\u662f\u4e00\u4e2a\u7a7a\u6307\u9488\u3002<\/li>\n<li>\u7b2c2~4\u4e2a\u53c2\u6570\u662f <code>[]string<\/code>\uff0c\u6211\u4eec\u90fd\u77e5\u9053\uff0cslice \u8fd9\u4e2a\u6570\u636e\u7ed3\u6784\u662f\u6709\u4e09\u4e2a\u5b57\u6bb5\u7ec4\u6210\uff1apointer, len, cap\u3002pointer(0xc000072f58) \u662f\u6307\u5411\u5b9e\u9645\u5185\u5b58\u5730\u5740\u7684\u6307\u9488\uff0clen(0x2) \u662f\u957f\u5ea6\uff0ccap(0x2) \u662f\u5bb9\u91cf\u3002<\/li>\n<li>\u7b2c 5 \u4e2a\u53c2\u6570\u662f\u8fd4\u56de\u503c\u3002<\/li>\n<\/ol>\n<\/li>\n<li><code>\/home\/jiangpengfei.jiangpf\/projects\/panic_demo\/main.go:14 +0x43<\/code>\u3002\u8fd9\u91cc\u6807\u51fa\u4e86\u51fa\u9519\u7684\u4ee3\u7801\u4f4d\u7f6e\u4ee5\u53ca\u884c\u53f7\u3002<code>+0x43<\/code> \u53c8\u4ee3\u8868\u4ec0\u4e48\u542b\u4e49\u5462\uff1f\u8bf4\u5b9e\u8bdd\u6211\u6ca1\u6709\u641c\u7d22\u5230\u76f8\u5173\u7684\u4fe1\u606f\u3002\u4f46\u662f\u627e\u5230\u4e86\u5982\u4e0b\u7684 go runtime \u7684\u4ee3\u7801[go\/src\/runtime\/traceback.go:439]\u3002frame \u4ee3\u8868\u5f53\u524d\u6808\u5e27\uff0cf \u4ee3\u8868\u5f53\u524d\u51fd\u6570\uff0centry \u662f\u8be5\u51fd\u6570\u7684 start pc\u3002\u56e0\u6b64\u53ef\u4ee5\u77e5\u9053 <code>+0x43<\/code> \u4ee3\u8868\u7684\u662f\u6808\u5185\u7684 pc \u504f\u79fb\u91cf\u3002\n<pre><code class=\"language-go line-numbers\">if frame.pc &gt; f.entry {\nprint(\" +\", hex(frame.pc-f.entry))\n}\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u81f3\u6b64\uff0c\u4e00\u4e2a\u7b80\u5355\u7684 panic \u4f8b\u5b50\u5206\u6790\u5b8c\u6bd5\u3002\u4f46\u662f\u8fd9\u91cc\u6211\u4eec\u8fd8\u6709\u4e24\u4e2a\u6ca1\u6709\u8bf4\u660e\u767d\u7684\u4e8b\u60c5\u3002<\/p>\n<ol>\n<li>panic \u65f6\u7684\u53c2\u6570\u5230\u5e95\u5982\u4f55\u5206\u6790\uff0c\u6bd4\u5982\u4e0a\u9762\u8bf4\u5230 slice \u7c7b\u578b\u7684\u53c2\u6570\u5728 panic \u65f6\uff0c\u4f1a\u8f93\u51fa pointer, len, cap \u8fd9\u4e09\u4e2a\u4fe1\u606f\u3002\u5176\u5b9e\u4e5f\u5c31\u662f\uff0c<strong>panic \u4e2d\u4f1a\u8f93\u51fa go \u7c7b\u578b\u7684\u5185\u5b58\u5e03\u5c40\u4fe1\u606f<\/strong>\u3002\u90a3\u4e48\u5bf9\u4e8e\u5176\u4ed6\u7684\u7c7b\u578b\u53c8\u662f\u4ec0\u4e48\u6837\u5b50\u7684\u5462\uff1f<\/li>\n<li>panic \u65f6\uff0cgo runtime \u662f\u5982\u4f55\u505a\u5230\u6536\u96c6\u5e76\u6253\u5370\u51fa\u4e0a\u8ff0\u7684\u6240\u6709\u4fe1\u606f\u5462\uff1f<\/li>\n<\/ol>\n<h2>go \u7c7b\u578b\u7684\u5185\u5b58\u5e03\u5c40<\/h2>\n<p>\u8fd9\u4e00\u90e8\u5206\u4e3b\u8981\u53c2\u8003\uff1a<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/research.swtch.com\/godata\">Go Data Structures<\/a> \u548c <a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/research.swtch.com\/interfaces\">Go Data Structures: Interfaces<\/a>\u3002\u5927\u5bb6\u4e5f\u53ef\u4ee5\u76f4\u63a5\u770b\u8fd9\u4e24\u7bc7\u6587\u7ae0\u3002<\/p>\n<h3>\u57fa\u672c\u7c7b\u578b<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png\" alt=\"basic type\" \/><\/p>\n<p>\u57fa\u672c\u7c7b\u578b\u7684\u5185\u5b58\u5e03\u5c40\u5f88\u597d\u7406\u89e3\uff0c\u4e0d\u591a\u9610\u8ff0\u3002<\/p>\n<h3>\u7ed3\u6784\u4f53\u548c\u6307\u9488<\/h3>\n<p>\u7ed3\u6784\u4f53\u7684\u5185\u5b58\u5e03\u5c40\u662f\u6309\u7167\u6210\u5458\u53d8\u91cf\u7684\u987a\u5e8f\u6765\u7684\u3002\u5f53\u7136\uff0c\u8fd8\u4f1a\u6709\u4e00\u4e9b\u5185\u5b58\u5bf9\u9f50\u7684\u4f18\u5316\uff0c\u4e0d\u8fc7\u4e0d\u5c5e\u4e8e\u672c\u7bc7\u6587\u7ae0\u7684\u8303\u56f4\u3002<\/p>\n<p>\u6bd4\u5982\u4e0b\u9762\u7684 Point \u7ed3\u6784\u4f53\u3002<\/p>\n<pre><code class=\"language-go line-numbers\">type Point struct { X, Y int }\n<\/code><\/pre>\n<p>\u5176\u5185\u5b58\u5e03\u5c40\u5982\u4e0b\uff1a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1a.png\" alt=\"struct and pointer\" \/><\/p>\n<p>\u5bf9\u4e8e\u6210\u5458\u53d8\u91cf\u975e\u57fa\u672c\u7c7b\u578b\uff0c\u5185\u5b58\u5e03\u5c40\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">type Rect1 struct { Min, Max Point }\ntype Rect2 struct { Min, Max *Point }\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1b_1.png\" alt=\"struct and pointer\" \/><\/p>\n<h3>\u5b57\u7b26\u4e32<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata2.png\" alt=\"string\" \/><\/p>\n<p>\u5b57\u7b26\u4e32\u4e3b\u8981\u7531\uff1apointer \u548c len \u7ec4\u6210\uff0c\u5176\u4e2d pointer \u6307\u5411 byte \u6570\u7ec4\u7684\u5185\u5b58\u9996\u5730\u5740\u3002\u540c\u65f6\uff0cgo \u4e2d\u7684 string \u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u56e0\u6b64\u591a\u4e2a\u5b57\u7b26\u4e32\u5171\u4eab\u540c\u4e00\u5757\u5185\u5b58\u533a\u57df\u662f\u5b89\u5168\u7684\u3002<\/p>\n<h3>\u5207\u7247<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata3.png\" alt=\"slice\" \/><\/p>\n<p>slice \u4e5f\u662f\u5f15\u7528\u5230\u6570\u7ec4\u7684\u4e00\u5757\u5185\u5b58\u5730\u5740\u4e0a\uff0c\u7531\u4e09\u4e2a\u5b57\u6bb5\u7ec4\u6210\uff1apointer, len \u548c cap<\/p>\n<h3>interface<\/h3>\n<p>(\u4e0b\u9762\u662f\u57fa\u4e8e 32 \u4f4d\u673a\u5668\u800c\u8a00)<\/p>\n<pre><code class=\"language-go line-numbers\">type Stringer interface {\n    String() string\n}\n\nfunc ToString(any interface{}) string {\n    if v, ok := any.(Stringer); ok {\n        return v.String()\n    }\n    switch v := any.(type) {\n    case int:\n        return strconv.Itoa(v)\n    case float:\n        return strconv.Ftoa(v, 'g', -1)\n    }\n    return \"???\"\n}\ntype Binary uint64\n\nfunc (i Binary) String() string {\n    return strconv.Uitob64(i.Get(), 2)\n}\n\nfunc (i Binary) Get() uint64 {\n    return uint64(i)\n}\n<\/code><\/pre>\n<p>\u4e0a\u9762\u5b9a\u4e49\u4e86 <code>Stringer<\/code> \u7c7b\u578b\uff0c<code>Binary<\/code> \u5b9e\u73b0\u4e86 <code>Stringer<\/code> \u7c7b\u578b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/gointer1.png\" alt=\"\" \/><\/p>\n<p>\u90a3\u4e48\uff0c\u56fe\u4e2d b \u7684\u5185\u5b58\u5e03\u5c40\u5982\u4e0b\u3002\u5c06 b \u505a\u7c7b\u578b\u8f6c\u6362\u6210 s \u540e\uff0c\u5185\u5b58\u5e03\u5c40\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/gointer2.png\" alt=\"\" \/><\/p>\n<p>\u8fd9\u91cc\uff0ctab \u6307\u5411\u4e86\u4e00\u4e2a itable<\/p>\n<ol>\n<li>itable \u4e2d\u7684 type \u6307\u5411\u4e86\u5e95\u5c42\u7c7b\u578b(Binary)\uff0c\u56e0\u6b64 s.tab->type \u5c31\u53ef\u4ee5\u83b7\u53d6\u8be5 interface \u7684\u7c7b\u578b\u3002<\/li>\n<li>itable \u7684 func \u6570\u7ec4\u4e2d\u53ea\u4fdd\u5b58\u5b9e\u73b0\u4e86 Stringer \u7684\u65b9\u6cd5\u6307\u9488\u3002\u6240\u4ee5 Get() \u5e76\u4e0d\u4f1a\u4fdd\u5b58\u5728\u8fd9\u91cc\u3002<\/li>\n<li>\u5728\u8c03\u7528 s.String() \u65f6\uff0c\u7b49\u540c\u4e8e\u8c03\u7528 <code>s.tab-&gt;func[0](s.data)<\/code>\u3002\u5c06 s.data \u4f5c\u4e3a\u7b2c\u4e00\u4e2a\u53c2\u6570\uff0c\u4f20\u8fdb\u51fd\u6570\u8c03\u7528\u4e2d\u3002\u8fd9\u91cc\u8fd8\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u56e0\u4e3a\u51fd\u6570\u8c03\u7528\u4f20\u8fdb\u53bb\u7684\u662f s.data\uff0c\u800c s.data \u7684\u7c7b\u578b\u662f *Binary\u3002\u56e0\u6b64 func[0] \u662f <code>(*Binary).String<\/code> \u800c\u4e0d\u662f <code>(Binary).String<\/code>\u3002<\/li>\n<\/ol>\n<p>data \u662f\u4e00\u4e2a\u6307\u9488\uff0c\u6307\u5411\u4e86 Binary(200)\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u5e76\u4e0d\u662f\u6307\u5411\u4e86\u539f\u59cb\u7684 b\uff0c\u800c\u662f b \u7684\u62f7\u8d1d\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u5e76\u4e0d\u662f\u6240\u6709\u60c5\u51b5\u90fd\u5982\u6b64\uff0c\u6bd4\u5982\u8bf4\uff0c\u5982\u679c\u5c06 b \u8f6c\u6362\u6210\u4e00\u4e2a\u6ca1\u6709\u65b9\u6cd5\u7684 interface\uff0c\u8fd9\u91cc\u5c31\u53ef\u4ee5\u5bf9\u5185\u5b58\u505a\u4e00\u4e0b\u4f18\u5316\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/gointer3.png\" alt=\"\" \/><\/p>\n<p>\u6b64\u65f6\uff0c\u56e0\u4e3a\u6ca1\u6709 func \u5217\u8868\uff0c\u6240\u4ee5\u5c31\u4e0d\u8981\u5355\u72ec\u4e3a itable \u5728\u5806\u4e0a\u5206\u914d\u4e00\u5757\u5185\u5b58\u4e86\u3002any.type \u76f4\u63a5\u6307\u5411\u4e00\u4e2a\u7c7b\u578b\u5c31\u53ef\u4ee5\u4e86\u3002\u540c\u6837\u7684\uff0c\u5982\u679c data \u6b63\u597d\u662f 32\u4f4d\uff08\u548c\u673a\u5668\u7684\u5bfb\u5740\u5927\u5c0f\u4e00\u81f4\uff09\uff0c\u90a3\u4e48\u4e5f\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u5c06\u503c\u4fdd\u5b58\u5728 data \u4e2d\u6765\u8fdb\u884c\u4f18\u5316\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/gointer4.png\" alt=\"\" \/><\/p>\n<p>\u4e0b\u9762\u662f\u4e24\u79cd\u4f18\u5316\u90fd\u53ef\u4ee5\u4eab\u53d7\u7684\u60c5\u51b5\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/gointer5.png\" alt=\"\" \/><\/p>\n<h2>\u53c2\u6570\u66f4\u591a\u7684\u4f8b\u5b50\u5206\u6790<\/h2>\n<p>\u5728\u4e86\u89e3\u5230\u4e0a\u8ff0\u7684 go \u7c7b\u578b\u7684\u5185\u5b58\u5e03\u5c40\u4e4b\u540e\uff0c\u4e0b\u9762\u770b\u4e00\u4e2a\u66f4\u591a\u53c2\u6570\u7684\u51fd\u6570\u8c03\u7528 panic\u3002<\/p>\n<pre><code class=\"language-go line-numbers\">package main\n\n\/\/go:noinline\nfunc test1(a int, b []int, c string, d [2]int64) error {\n    panic(\"test1\")\n}\n\nfunc main() {\n    a := 0\n    b := make([]int, 3, 7)\n    b[0], b[1], b[2] = 1, 2, 3\n    c := \"c\"\n    d := [2]int64{5, 6}\n\n    test1(a, b, c, d)\n}\n<\/code><\/pre>\n<p>\u6ce8\u610f\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86 <code>\/\/go:noinline<\/code> \u6765\u9632\u6b62 go \u7f16\u8bd1\u65f6\u5bf9\u51fd\u6570\u8fdb\u884c\u5185\u8054\uff0c\u8fd9\u6837 panic \u540e\u5c31\u4f1a\u4e22\u5931\u53c2\u6570\u4fe1\u606f\u3002panic \u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash line-numbers\">main.test1(0x0, 0xc00003a740, 0x3, 0x7, 0x475848, 0x1, 0x5, 0x6, 0x4046eb, 0xc000058000)\n<\/code><\/pre>\n<p>\u89e3\u91ca\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">main.test1(0x0, \/\/ a \u7684\u503c\n           0xc00003a710, \/\/ b \u6307\u5411\u7684\u5185\u5b58\u5730\u5740\n           0x3, \/\/ b \u7684 len\n           0x7, \/\/ b \u7684 cap\n           0x475a48, \/\/ c \u6307\u5411\u7684\u5185\u5b58\u5730\u5740\n           0x1, \/\/ c \u7684\u957f\u5ea6\n           0x5, \/\/ d[0]\n           0x6, \/\/ d[1]\n           0x4046eb, \/\/ \n           0xc000058000) \/\/ error \u7684\u503c\n<\/code><\/pre>\n<p>\u5982\u679c\u6211\u4eec\u5e0c\u671b\u770b\u5230\u6ca1\u6709\u4f18\u5316\u8fc7\u7684 error \u503c\u3002\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u6765\u8fd0\u884c\uff1a<\/p>\n<pre><code class=\"language-bash line-numbers\">go run -gcflags '-N -l' main.go\n<\/code><\/pre>\n<p>\u8fd9\u6837\u7684\u8bdd\uff0c\u6700\u540e\u4e24\u4e2a\u53c2\u6570\u5c31\u90fd\u662f <code>0x0<\/code>\u3002\u518d\u6765\u4e00\u4e2a\u548c\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u4f8b\u5b50:<\/p>\n<pre><code class=\"language-go line-numbers\">package main\n\ntype speaker interface {\n    say()\n}\n\ntype person struct {\n    name string\n    age  int\n}\n\nfunc (p person) say() {\n}\n\n\/\/go:noinline\nfunc test2(p1 person, p2 *person, p3 speaker) error {\n    panic(\"test2\")\n    return nil\n}\n\nfunc main() {\n    p1 := person{\"p\", 11}\n    p2 := new(person)\n    p3 := speaker(p1)\n\n    test2(p1, p2, p3)\n}\n<\/code><\/pre>\n<p>\u4f7f\u7528 <code>go run -gcflags '-N -l' main.go<\/code> \u8fd0\u884c\u540e panic \u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash line-numbers\">main.test2(0x475a48, 0x1, 0xb, 0xc00003a748, 0x487200, 0xc00003a730, 0x0, 0x0)\n<\/code><\/pre>\n<p>\u89e3\u91ca\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">main.test2(0x475a49, \/\/ person.name \u6307\u5411\u7684\u5185\u5b58\u5730\u5740\n           0x1, \/\/ person.name \u7684\u957f\u5ea6\n           0xb, \/\/ person.age \u7684\u503c\n           0xc00003a748, \/\/ p2 \u7684\u6307\u9488\u503c\n           0x487200, \/\/ p3 \u6307\u5411\u7684 itable \u4e2d\u7684 type\n           0xc00003a730, \/\/ p3 \u6307\u5411\u7684 p1 \u7684\u62f7\u8d1d\u7684\u5185\u5b58\u5730\u5740\n           0x0, \/\/ error \u7684\u7c7b\u578b\n           0x0) \/\/ error \u7684\u503c\n<\/code><\/pre>\n<h2>go panic \u540e\u7684\u6267\u884c\u8fc7\u7a0b<\/h2>\n<p>goroutine \u4e0a\u53d1\u751f panic \u540e\uff0c\u4f1a\u8fdb\u5165\u51fd\u6570\u9000\u51fa\u9636\u6bb5\u3002\u4ee5\u624b\u52a8\u8c03\u7528 <code>panic<\/code> \u4e3a\u4f8b\u3002<\/p>\n<ol>\n<li>\u9996\u5148\uff0cgo runtime \u4f1a\u5c06\u8be5 panic \u653e\u5230 goroutine \u7684 panic \u94fe\u8868\u9996\u3002<\/li>\n<\/ol>\n<pre><code class=\"language-go line-numbers\">var p _panic\np.arg = e       \/\/ arg \u662f panic \u7684\u53c2\u6570\np.link = gp._panic \/\/ link \u6307\u5411\u66f4\u65e9\u7684 panic\ngp._panic = (*_panic)(noescape(unsafe.Pointer(&amp;p))) \/\/ gp \u662f\u5f53\u524d goroutine \u534f\u7a0b\n<\/code><\/pre>\n<ol start=\"2\">\n<li>\u63a5\u7740\uff0c\u4f1a\u4f9d\u6b21\u6267\u884c goroutine \u4e0a\u7684 defer\u3002\n<pre><code class=\"language-go line-numbers\">for {\n    d := gp._defer\n    if d == nil {\n        break\n    }\n   ...\n   ...\n}\n<\/code><\/pre>\n<\/li>\n<li>\u5982\u679c\u8be5 defer \u4e4b\u524d\u5df2\u7ecf\u6267\u884c\u8fc7\u4e86\u3002\u5219\u76f4\u63a5\u5ffd\u7565\u8be5 defer\n<pre><code class=\"language-go line-numbers\">\/\/ If defer was started by earlier panic or Goexit (and, since we're back here, that triggered a new panic),\n\/\/ take defer off list. The earlier panic or Goexit will not continue running.\nif d.started {\n if d._panic != nil {\n   d._panic.aborted = true\n }\n d._panic = nil\n d.fn = nil\n gp._defer = d.link\n freedefer(d)\n continue\n}\n<\/code><\/pre>\n<\/li>\n<li>\u6267\u884c defer \u5bf9\u5e94\u7684\u51fd\u6570\u8c03\u7528\u3002\n<pre><code class=\"language-go line-numbers\">reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))\n<\/code><\/pre>\n<\/li>\n<li>\u5982\u679c defer \u51fd\u6570\u4e2d\u9047\u5230\u4e86 recover()\uff0c\u8fd8\u4f1a\u6267\u884c\u4ee5\u4e0b\u4ee3\u7801\u3002\u5f53\u7136\uff0c\u8fd9\u91cc\u53ea\u4f1a\u68c0\u67e5 recover() \u8c03\u7528\u662f\u5426\u6709\u6548\n<ol>\n<li>p != nil\u3002\u5f53\u524d\u786e\u5b9e\u53d1\u751f panic \u4e86\u3002<\/li>\n<li>!p.recovered\u3002\u5f53\u524d\u7684 panic \u6ca1\u6709\u6062\u590d<\/li>\n<li>argp <span class=\"text-highlighted-inline\" style=\"background-color: #fffd38;\"> uintptr(p.argp)\u3002argp \u662f\u8c03\u7528\u8005\u7684\u53c2\u6570\u6307\u9488\uff0cp.argp \u662f defer \u7684\u53c2\u6570\u3002<\/span><\/li>\n<li>\u5982\u679c\u4e0a\u8ff0\u6761\u4ef6\u4e4b\u4e00\u4e0d\u6ee1\u8db3\uff0c\u5c31\u8fd4\u56de nil\uff0c\u8868\u793a\u8fd9\u4e2a recover() \u662f\u65e0\u6548\u7684\u3002<\/li>\n<\/ol>\n<pre><code class=\"language-go line-numbers\">func gorecover(argp uintptr) interface{} {\n\/\/ Must be in a function running as part of a deferred call during the panic.\n\/\/ Must be called from the topmost function of the call\n\/\/ (the function used in the defer statement).\n\/\/ p.argp is the argument pointer of that topmost deferred function call.\n\/\/ Compare against argp reported by caller.\n\/\/ If they match, the caller is the one who can recover.\ngp := getg()\np := gp._panic\nif p != nil &amp;&amp; !p.recovered &amp;&amp; argp == uintptr(p.argp) {\n    p.recovered = true\n    return p.arg\n}\nreturn nil\n}\n<\/code><\/pre>\n<\/li>\n<li>\u4e0a\u4e00\u6b65\u867d\u7136\u662f recover() \u8c03\u7528\uff0c\u4f46\u5e76\u6ca1\u6709 recover \u7684\u903b\u8f91\uff0c\u53ea\u662f\u7ed9\u5f53\u524d panic \u6807\u8bb0\u4e86 recovered=true\u3002\u6240\u4ee5\u53ef\u4ee5\u6267\u884c\u5230\u4e0b\u9762\u8fd9\u4e2a\u5224\u65ad\u3002\u901a\u8fc7 <code>mcall(recovery)<\/code> \u6765\u6267\u884c\u771f\u6b63\u7684\u6062\u590d\u903b\u8f91\u3002\n<pre><code class=\"language-go line-numbers\">if p.recovered {\n        atomic.Xadd(&amp;runningPanicDefers, -1)\n\n        gp._panic = p.link\n        \/\/ Aborted panics are marked but remain on the g.panic list.\n        \/\/ Remove them from the list.\n        for gp._panic != nil &amp;&amp; gp._panic.aborted {\n            gp._panic = gp._panic.link\n        }\n        if gp._panic == nil { \/\/ must be done with signal\n            gp.sig = 0\n        }\n        \/\/ Pass information about recovering frame to recovery.\n        gp.sigcode0 = uintptr(sp)\n        gp.sigcode1 = pc\n        mcall(recovery)\n        throw(\"recovery failed\") \/\/ mcall should not return\n}\n<\/code><\/pre>\n<\/li>\n<li>\u6062\u590d\u5b9e\u73b0\u5982\u4e0b\n<pre><code class=\"language-go line-numbers\">\/\/ Unwind the stack after a deferred function calls recover\n\/\/ after a panic. Then arrange to continue running as though\n\/\/ the caller of the deferred function returned normally.\nfunc recovery(gp *g) {\n\/\/ Info about defer passed in G struct.\nsp := gp.sigcode0\npc := gp.sigcode1\n\n\/\/ d's arguments need to be in the stack.\nif sp != 0 &amp;&amp; (sp &lt; gp.stack.lo || gp.stack.hi &lt; sp) {\n    print(\"recover: \", hex(sp), \" not in [\", hex(gp.stack.lo), \", \", hex(gp.stack.hi), \"]\\n\")\n    throw(\"bad recovery\")\n}\n\n\/\/ Make the deferproc for this d return again,\n\/\/ this time returning 1.  The calling function will\n\/\/ jump to the standard return epilogue.\ngp.sched.sp = sp\ngp.sched.pc = pc\ngp.sched.lr = 0\ngp.sched.ret = 1\ngogo(&amp;gp.sched)\n}\n<\/code><\/pre>\n<\/li>\n<li>\u5982\u679c\u6ca1\u6709\u6062\u590d\u903b\u8f91\u7684\u8bdd\uff0c\u5c31\u6267\u884c\u5230\u8f93\u51fa\u5f02\u5e38\u4fe1\u606f\u7684\u5730\u65b9\u4e86\u3002\n<pre><code class=\"language-go line-numbers\">\/\/ ran out of deferred calls - old-school panic now\n\/\/ Because it is unsafe to call arbitrary user code after freezing\n\/\/ the world, we call preprintpanics to invoke all necessary Error\n\/\/ and String methods to prepare the panic strings before startpanic.\npreprintpanics(gp._panic)\n\nfatalpanic(gp._panic) \/\/ should not return\n<\/code><\/pre>\n<\/li>\n<li><code>preprintpanics<\/code> \u8d1f\u8d23\u51c6\u5907\u8981\u6253\u5370\u7684\u4fe1\u606f\u3002\u5373\u5982\u679c panic \u53c2\u6570\u662f error\uff0c\u5c31\u4ece v.Error() \u4e2d\u83b7\u53d6\u9519\u8bef\u4fe1\u606f\u3002\u5982\u679c\u53c2\u6570\u5b9e\u73b0\u4e86 stringer\uff0c\u5219\u8c03\u7528 String() \u6765\u83b7\u53d6\u5b57\u7b26\u4e32\u4fe1\u606f\u3002\n<pre><code class=\"language-go line-numbers\">\/\/ Call all Error and String methods before freezing the world.\n\/\/ Used when crashing with panicking.\nfunc preprintpanics(p *_panic) {\ndefer func() {\n    if recover() != nil {\n        throw(\"panic while printing panic value\")\n    }\n}()\nfor p != nil {\n    switch v := p.arg.(type) {\n    case error:\n        p.arg = v.Error()\n    case stringer:\n        p.arg = v.String()\n    }\n    p = p.link\n}\n}\n<\/code><\/pre>\n<\/li>\n<li><code>fatalpanic<\/code> \u5f00\u59cb\u6700\u540e\u7684\u5f02\u5e38\u4fe1\u606f\u8f93\u51fa\u3002\u9996\u5148\u9012\u5f52\u8c03\u7528 <code>printpanics<\/code> \u6765\u6253\u5370 panic \u7684\u53c2\u6570\u3002\n<pre><code class=\"language-go line-numbers\">\/\/ Print all currently active panics. Used when crashing.\n\/\/ Should only be called after preprintpanics.\nfunc printpanics(p *_panic) {\n    if p.link != nil {\n        printpanics(p.link)\n        print(\"\\t\")\n    }\n    print(\"panic: \")\n    printany(p.arg)\n    if p.recovered {\n        print(\" [recovered]\")\n    }\n    print(\"\\n\")\n}\n<\/code><\/pre>\n<\/li>\n<li>\n<p>\u6700\u540e\u8c03\u7528 <code>dopanic_m<\/code> \u6765\u6253\u5370\u5f02\u5e38\u8c03\u7528\u6808\uff0c\u7136\u540e <code>exit(2)<\/code>\u9000\u51fa<\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8ff0 \u4f5c\u4e3a\u4e00\u4e2a\u7ecf\u5e38\u5199 go \u7684\u7a0b\u5e8f\u5458\uff0c\u80af\u5b9a\u65f6\u4e0d\u65f6\u4f1a\u770b\u5230 go \u7684 panic \u4fe1\u606f\u3002\u4e00\u822c\u6211\u4eec\u90fd\u53ef\u4ee5\u6839\u636e\u4fe1\u606f\u8f7b\u677e &hellip; <a href=\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67],"tags":[],"class_list":["post-808","post","type-post","status-publish","format-standard","hentry","category-go"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f - \u4e00\u53ea\u5b89\u9759\u7684\u732b<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f - \u4e00\u53ea\u5b89\u9759\u7684\u732b\" \/>\n<meta property=\"og:description\" content=\"\u6982\u8ff0 \u4f5c\u4e3a\u4e00\u4e2a\u7ecf\u5e38\u5199 go \u7684\u7a0b\u5e8f\u5458\uff0c\u80af\u5b9a\u65f6\u4e0d\u65f6\u4f1a\u770b\u5230 go \u7684 panic \u4fe1\u606f\u3002\u4e00\u822c\u6211\u4eec\u90fd\u53ef\u4ee5\u6839\u636e\u4fe1\u606f\u8f7b\u677e &hellip; \u7ee7\u7eed\u9605\u8bfb\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\" \/>\n<meta property=\"og:site_name\" content=\"\u4e00\u53ea\u5b89\u9759\u7684\u732b\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-22T16:36:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-05T02:01:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png\" \/>\n<meta name=\"author\" content=\"jiangpengfei\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"jiangpengfei\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\"},\"author\":{\"name\":\"jiangpengfei\",\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"headline\":\"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f\",\"datePublished\":\"2021-03-22T16:36:52+00:00\",\"dateModified\":\"2023-07-05T02:01:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\"},\"wordCount\":161,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"image\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png\",\"articleSection\":[\"go\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\",\"url\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\",\"name\":\"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f - \u4e00\u53ea\u5b89\u9759\u7684\u732b\",\"isPartOf\":{\"@id\":\"https:\/\/www.myway5.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png\",\"datePublished\":\"2021-03-22T16:36:52+00:00\",\"dateModified\":\"2023-07-05T02:01:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage\",\"url\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png\",\"contentUrl\":\"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png\",\"width\":409,\"height\":303},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.myway5.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.myway5.com\/#website\",\"url\":\"https:\/\/www.myway5.com\/\",\"name\":\"\u4e00\u53ea\u5b89\u9759\u7684\u732b\",\"description\":\"\u60f3\u5565\u5462\",\"publisher\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.myway5.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\",\"name\":\"jiangpengfei\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g\",\"caption\":\"jiangpengfei\"},\"logo\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.myway5.com\/index.php\/author\/joyme\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f - \u4e00\u53ea\u5b89\u9759\u7684\u732b","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":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/","og_locale":"zh_CN","og_type":"article","og_title":"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f - \u4e00\u53ea\u5b89\u9759\u7684\u732b","og_description":"\u6982\u8ff0 \u4f5c\u4e3a\u4e00\u4e2a\u7ecf\u5e38\u5199 go \u7684\u7a0b\u5e8f\u5458\uff0c\u80af\u5b9a\u65f6\u4e0d\u65f6\u4f1a\u770b\u5230 go \u7684 panic \u4fe1\u606f\u3002\u4e00\u822c\u6211\u4eec\u90fd\u53ef\u4ee5\u6839\u636e\u4fe1\u606f\u8f7b\u677e &hellip; \u7ee7\u7eed\u9605\u8bfb\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f","og_url":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/","og_site_name":"\u4e00\u53ea\u5b89\u9759\u7684\u732b","article_published_time":"2021-03-22T16:36:52+00:00","article_modified_time":"2023-07-05T02:01:24+00:00","og_image":[{"url":"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png","type":"","width":"","height":""}],"author":"jiangpengfei","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"jiangpengfei","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#article","isPartOf":{"@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/"},"author":{"name":"jiangpengfei","@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"headline":"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f","datePublished":"2021-03-22T16:36:52+00:00","dateModified":"2023-07-05T02:01:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/"},"wordCount":161,"commentCount":1,"publisher":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"image":{"@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage"},"thumbnailUrl":"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png","articleSection":["go"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/","url":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/","name":"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f - \u4e00\u53ea\u5b89\u9759\u7684\u732b","isPartOf":{"@id":"https:\/\/www.myway5.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage"},"image":{"@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage"},"thumbnailUrl":"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png","datePublished":"2021-03-22T16:36:52+00:00","dateModified":"2023-07-05T02:01:24+00:00","breadcrumb":{"@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#primaryimage","url":"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png","contentUrl":"https:\/\/www.myway5.com\/wp-content\/uploads\/2021\/03\/godata1.png","width":409,"height":303},{"@type":"BreadcrumbList","@id":"https:\/\/www.myway5.com\/index.php\/2021\/03\/23\/go-panic\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.myway5.com\/"},{"@type":"ListItem","position":2,"name":"\u8bfb\u61c2 go \u7684 panic \u4fe1\u606f"}]},{"@type":"WebSite","@id":"https:\/\/www.myway5.com\/#website","url":"https:\/\/www.myway5.com\/","name":"\u4e00\u53ea\u5b89\u9759\u7684\u732b","description":"\u60f3\u5565\u5462","publisher":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.myway5.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685","name":"jiangpengfei","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.myway5.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g","caption":"jiangpengfei"},"logo":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/image\/"},"url":"https:\/\/www.myway5.com\/index.php\/author\/joyme\/"}]}},"views":7135,"_links":{"self":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/comments?post=808"}],"version-history":[{"count":1,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/808\/revisions"}],"predecessor-version":[{"id":809,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/808\/revisions\/809"}],"wp:attachment":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/media?parent=808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/categories?post=808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/tags?post=808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}