{"id":44242,"date":"2023-02-13T19:23:40","date_gmt":"2023-11-30T12:23:03","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/"},"modified":"2024-04-29T14:29:36","modified_gmt":"2024-04-29T06:29:36","slug":"%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/","title":{"rendered":"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d"},"content":{"rendered":"<h1>\u3010Golang\u3011\u53d1\u751f\u6050\u614c\u3001\u6062\u590d<\/h1>\n<p>\u7d93\u904e\u57fa\u790e\u5b78\u7fd2\u5f8c\uff0c\u6211\u5b8c\u6210\u4e86\u5b78\u7fd2Golang\u4e26\u5275\u5efaWeb\u61c9\u7528\u7a0b\u5e8f\u7684\u904e\u7a0b\uff0c\u73fe\u5728\u6211\u5c07\u9032\u884c\u5fa9\u7fd2\u4e26\u6574\u7406\u7b46\u8a18\uff0c\u5305\u62ec\u5f9e\u57fa\u790e\u5230\u61c9\u7528\u7a0b\u5f0f\u7684\u7bc4\u570d\u3002<\/p>\n<pre class=\"post-pre\"><code>package main\r\n\/\/\u30d1\u30cb\u30c3\u30af\uff08\u4f8b\u5916\uff09\u3001\u30ea\u30ab\u30d0\u30ea\u30fc\uff08\u5fa9\u5e30\uff09\r\n\/\/\u30d1\u30cb\u30c3\u30af\u3088\u308a\u63a8\u5968\u3055\u308c\u3066\u3044\u308b\u306e\u306f\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\r\n\/\/\u5f37\u5236\u7684\u306b\u7d42\u4e86\u3059\u308b\u5f37\u529b\u306a\u6a5f\u80fd\u306a\u70ba\u3001\u3042\u3048\u3066\u4f7f\u308f\u306a\u3044\u65b9\u304c\u3044\u3044\r\n\r\nimport (\r\n    \"fmt\"\r\n)\r\n\r\n\/\/\u5916\u90e8DB\u63a5\u7d9a\u3092\u30a4\u30e1\u30fc\u30b8\r\nfunc thirdPartyConnectDB() {\r\n    \/\/\u30d1\u30cb\u30c3\u30af\u3092\u8d77\u3053\u3059\u3002\u4f8b\u5916\u3092\u767a\u751f\u3055\u305b\u308b\u3002\r\n    panic(\"Unable to connect database!\")\r\n}\r\n\r\nfunc save() {\r\n    \/\/defer\u3092\u5148\u306b\u66f8\u304f\r\n    defer func() {\r\n        \/\/\u30ea\u30ab\u30d0\u30ea\u30fc \u30b7\u30b9\u30c6\u30e0\u7d42\u4e86\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u5fa9\u5e30\u3055\u305b\u308b\u3002\r\n        s := recover()\r\n        fmt.Println(s)\r\n    }()\r\n    thirdPartyConnectDB()\r\n}\r\n\r\nfunc main(){\r\n    save()\r\n    fmt.Println(\"\u30ea\u30ab\u30d0\u30fc\u3057\u3066\u3044\u308b\u306e\u3067\u8868\u793a\u3055\u308c\u308b\")\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3010Golang\u3011\u53d1\u751f\u6050\u614c\u3001\u6062\u590d \u7d93\u904e\u57fa\u790e\u5b78\u7fd2\u5f8c\uff0c\u6211\u5b8c\u6210\u4e86\u5b78\u7fd2Golang\u4e26\u5275\u5efaWeb\u61c9\u7528\u7a0b\u5e8f\u7684\u904e\u7a0b\uff0c\u73fe\u5728\u6211\u5c07\u9032 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-44242","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d - Blog - Silicon Cloud<\/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.silicloud.com\/zh\/blog\/\u3010go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d\" \/>\n<meta property=\"og:description\" content=\"\u3010Golang\u3011\u53d1\u751f\u6050\u614c\u3001\u6062\u590d \u7d93\u904e\u57fa\u790e\u5b78\u7fd2\u5f8c\uff0c\u6211\u5b8c\u6210\u4e86\u5b78\u7fd2Golang\u4e26\u5275\u5efaWeb\u61c9\u7528\u7a0b\u5e8f\u7684\u904e\u7a0b\uff0c\u73fe\u5728\u6211\u5c07\u9032 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u3010go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-30T12:23:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T06:29:36+00:00\" \/>\n<meta name=\"author\" content=\"\u9038, \u79d1\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u9038, \u79d1\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/\",\"name\":\"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-11-30T12:23:03+00:00\",\"dateModified\":\"2024-04-29T06:29:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487\",\"name\":\"\u9038, \u79d1\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g\",\"caption\":\"\u9038, \u79d1\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keyi\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d - Blog - Silicon Cloud","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.silicloud.com\/zh\/blog\/\u3010go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d\/","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d","og_description":"\u3010Golang\u3011\u53d1\u751f\u6050\u614c\u3001\u6062\u590d \u7d93\u904e\u57fa\u790e\u5b78\u7fd2\u5f8c\uff0c\u6211\u5b8c\u6210\u4e86\u5b78\u7fd2Golang\u4e26\u5275\u5efaWeb\u61c9\u7528\u7a0b\u5e8f\u7684\u904e\u7a0b\uff0c\u73fe\u5728\u6211\u5c07\u9032 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u3010go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-11-30T12:23:03+00:00","article_modified_time":"2024-04-29T06:29:36+00:00","author":"\u9038, \u79d1","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u9038, \u79d1"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/","name":"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-11-30T12:23:03+00:00","dateModified":"2024-04-29T06:29:36+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u3010Go\u8bed\u8a00\u3011\u53d1\u751f\u6050\u614c\uff0c\u6062\u590d"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487","name":"\u9038, \u79d1","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g","caption":"\u9038, \u79d1"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keyi\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e3%80%90go%e8%af%ad%e8%a8%80%e3%80%91%e5%8f%91%e7%94%9f%e6%81%90%e6%85%8c%ef%bc%8c%e6%81%a2%e5%a4%8d\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/44242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=44242"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/44242\/revisions"}],"predecessor-version":[{"id":85828,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/44242\/revisions\/85828"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=44242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=44242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=44242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}