{"id":138297,"date":"2020-07-21T08:54:22","date_gmt":"2020-07-21T00:54:22","guid":{"rendered":"http:\/\/4563.org\/?p=138297"},"modified":"2020-07-21T08:54:22","modified_gmt":"2020-07-21T00:54:22","slug":"golang-panic-%e4%b8%8d%e6%89%93%e5%8d%b0%e5%8f%82%e6%95%b0%e5%9c%b0%e5%9d%80%e6%80%8e%e4%b9%88%e5%8a%9e%ef%bc%8c%e6%98%af%e4%b8%89%e4%b8%aa%e7%82%b9","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=138297","title":{"rendered":"golang panic \u4e0d\u6253\u5370\u53c2\u6570\u5730\u5740\u600e\u4e48\u529e\uff0c\u662f\u4e09\u4e2a\u70b9"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  golang panic \u4e0d\u6253\u5370\u53c2\u6570\u5730\u5740\u600e\u4e48\u529e\uff0c\u662f\u4e09\u4e2a\u70b9               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sunshinev <\/span>  <span><i><\/i> 12<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>2020\/07\/17 20:01:56 0xc0000721e0 1 panic: wtf  goroutine 1 [running]: main.run(...)  \/www\/xx\/go\/test\/main.go:18 main.main()  \/www\/xx\/go\/test\/main.go:13 +0xd0  Process finished with exit code 2  <\/code><\/pre>\n<p>\u4e3a\u4ec0\u4e48 run \u91cc\u9762\u662f&#8230;<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre><code>func main() {  a := \"1\"  run(a) }  func run(a string) {  log.Println(a)  panic(\"wtf\") }  <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2571227\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : katsusan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             run \u51fd\u6570\u88ab\u5185\u8054\u4e86\uff0c\u53ef\u4ee5\u5728\u7f16\u8bd1\u65f6\u52a0\u5165-gcflags &#8220;-l&#8221;\u7981\u6b62\u5185\u8054\u3002<\/p>\n<p>\u279c \/tmp go build -gcflags &#8220;-m&#8221; panic.go<br \/># command-line-arguments<br \/>.\/panic.go:10:6: can inline run<br \/>.\/panic.go:5:6: can inline main<br \/>.\/panic.go:7:5: inlining call to run<br \/>.\/panic.go:7:5: main &#8230; argument does not escape<br \/>.\/panic.go:7:5: a escapes to heap<br \/>.\/panic.go:10:10: leaking param: a<br \/>.\/panic.go:11:13: run &#8230; argument does not escape<br \/>.\/panic.go:11:13: a escapes to heap                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>golang panic \u4e0d\u6253\u5370\u53c2&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\/138297"}],"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=138297"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/138297\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=138297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=138297"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=138297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}