{"id":2649,"date":"2023-10-16T15:16:38","date_gmt":"2023-10-16T07:16:38","guid":{"rendered":"https:\/\/white-night.club\/?p=2649"},"modified":"2023-11-09T11:07:49","modified_gmt":"2023-11-09T03:07:49","slug":"pg9","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/16\/pg9\/","title":{"rendered":"MIT6.5830 Lab0-Go tutorial\u5b9e\u9a8c\u8bb0\u5f55\uff08\u4e8c\uff09"},"content":{"rendered":"\n<p>\u5728\u5c06\u6570\u636e\u5e93\u7684\u6570\u636e\u8f6c\u6362\u4e3a\u56fe\u8868\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u6d4b\u8bd5\u662f\u5426\u80fd\u6b63\u5e38\u8bbf\u95ee\u6570\u636e\u5e93\u6587\u4ef6\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u4e3a\u4ec0\u4e48\u8981\u600e\u4e48\u505a\uff1f\u56e0\u4e3a\u8fd9\u5757<strong>\u975e\u5e38\u5bb9\u6613\u51fa\u95ee\u9898<\/strong>\u3002\u5728handlers\u4e2d\u9700\u8981\u6211\u4eec\u8fde\u63a5\u81f3\u6570\u636e\u5e93\uff0c\u5e76\u5c06\u6570\u636e\u8f6c\u6362\u4e3a\u56fe\u7247\u5448\u73b0\u5728\u524d\u7aef\u7684html\u9875\u9762\u4e0a\u3002<br>\u95ee\u9898\u5728\u4e8e\u8fd9\u91cc\u5404\u79cd\u62a5\u9519\u539f\u56e0\u90fd\u6709\uff0c\u800c\u4e14\u5728lab0\u539f\u672c\u7684\u4ee3\u7801\u4e0a\u8fdb\u884c\u8c03\u8bd5\u975e\u5e38\u6298\u78e8\uff0c\u65ad\u70b9\u7ecf\u5e38\u8981\u6253\u4e0a\u4e00\u5806\u3002\u4f46\u662f\u7531\u4e8e\u6211\u662f\u5148\u505a\u5b8c\u5b9e\u9a8c\uff0c\u518d\u5199\u7684\u5b9e\u9a8c\u62a5\u544a\uff0c\u6240\u4ee5\u5b9e\u9a8c\u8fc7\u7a0b\u4e2d\u6709\u5f88\u591a\u56fe\u6ca1\u622a\u4e0b\u6765\u3002\u8fd9\u91cc\u53ea\u80fd\u63d0\u4f9b\u4e00\u4e2a\u5927\u81f4\u601d\u8def\u4e86\u3002<\/cite><\/blockquote>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u5b9e\u9a8c\u6b65\u9aa4<\/p>\n<cite><em>\u65b0\u5efago\u9879\u76ee\u4ee5\u6d4b\u8bd5\u94fe\u63a5<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u65b0\u5efa\u4e00\u4e2ago\u9879\u76ee\uff0c\u53ea\u9700\u8981\u6709\u4e00\u4e2amain.go\u5373\u53ef\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"771\" height=\"150\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/becfebe00ed5869271fa1a8e461887c.png\" alt=\"\" class=\"wp-image-2650\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/becfebe00ed5869271fa1a8e461887c.png 771w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/becfebe00ed5869271fa1a8e461887c-300x58.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/becfebe00ed5869271fa1a8e461887c-768x149.png 768w\" sizes=\"(max-width: 771px) 100vw, 771px\" \/><\/figure>\n\n\n\n<p>\u6253\u5f00main.go\u3002\u73b0\u5728\u6211\u4eec\u9700\u8981\u5148\u8bd5\u7740\u8bbf\u95ee\u6570\u636e\u5e93\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u81ea\u5df1\u7f16\u5199\u4e5f\u53ef\u4ee5\uff0c\u8fd9\u91cc\u6211\u9009\u62e9\u7528lab0\u4e2dsqlite_ridership_db\u4e2d\u7684SQL\u6765\u505a\u6d4b\u8bd5\u3002SQL\u8bed\u53e5\u5f88\u663e\u773c\uff0c\u6240\u4ee5\u8fd8\u662f\u4e0d\u96be\u627e\u7684\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"549\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/43d97d2bb4bd5def7813f103acebdb2-1024x549.png\" alt=\"\" class=\"wp-image-2651\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/43d97d2bb4bd5def7813f103acebdb2-1024x549.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/43d97d2bb4bd5def7813f103acebdb2-300x161.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/43d97d2bb4bd5def7813f103acebdb2-768x412.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/43d97d2bb4bd5def7813f103acebdb2-1536x824.png 1536w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/43d97d2bb4bd5def7813f103acebdb2.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5148\u628aSQL\u8bed\u53e5\u5199\u597d\uff0c\u5176\u4ed6\u7684\u529f\u80fd\u5f85\u4f1a\u518d\u8865\u9f50\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport (\n\t_ \"github.com\/mattn\/go-sqlite3\"\n)\n\nfunc main() {\n\n\tquery := `\n\t\tSELECT SUM(total_ons)\n\t\tFROM rail_ridership\n\t\tWHERE season = 'Fall 2017'\n\t\t\tAND time_period_id NOT IN ('time_period_10', 'time_period_11')\n\t\t\tAND line_id = ?\n\t\tGROUP BY time_period_id\n\t\tORDER BY time_period_id;\n\t`\n\n}\n<\/code><\/pre>\n\n\n\n<p><em>&#8220;github.com\/mattn\/go-sqlite3&#8221;<\/em>\u8fd9\u4e1c\u897f\u662f\u4e00\u4e2a\u6570\u636e\u5e93\u9a71\u52a8\u7684\u5305\uff0c\u5bfc\u5165\u5b83\u4e4b\u540e\u5c31\u53ef\u4ee5\u901a\u8fc7GO\u5bf9sqlite\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>db, err := sql.Open(\"sqlite3\", \"<em>\u5efa\u8bae\u4f7f\u7528\u6570\u636e\u5e93\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84<\/em>\")\nif err != nil {\n\tlog.Fatal(err)\n}\ndefer db.Close()\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#00ff2f\" class=\"has-inline-color\">\/\/\u8981\u517b\u6210\u6253\u5f00\u6570\u636e\u5e93\u540e\u5173\u95ed\u94fe\u63a5\u7684\u4e60\u60ef<\/mark><\/code><\/pre>\n\n\n\n<p>\u6b64\u65f6\u4f60\u7684main.go\u4ee3\u7801\u5e94\u8be5\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport (\n\t\"database\/sql\"\n\t\"fmt\"\n\t\"log\"\n\n\t_ \"github.com\/mattn\/go-sqlite3\"\n)\n\nfunc main() {\n\tdb, err := sql.Open(\"sqlite3\", \"c:\/Users\/LENOVO\/Desktop\/template\/testgo\/mbta.sqlite\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer db.Close()\n\tquery := `\n\t\tSELECT SUM(total_ons)\n\t\tFROM rail_ridership\n\t\tWHERE season = 'Fall 2017'\n\t\t\tAND time_period_id NOT IN ('time_period_10', 'time_period_11')\n\t\t\tAND line_id = ?\n\t\tGROUP BY time_period_id\n\t\tORDER BY time_period_id;\n\t`\n\n}\n<\/code><\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5bf9db\u6267\u884c\u4e9b\u64cd\u4f5c\u624d\u80fd\u77e5\u9053\u5230\u5e95\u6709\u6ca1\u6709\u6210\u529f\u8fde\u63a5\uff0c\u6211\u4eec\u5148\u770b\u770b\u539f\u672c\u5728lab0\u4e2d\u8fd9\u4e2aSQL\u8d77\u4ec0\u4e48\u4f5c\u7528\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"782\" height=\"351\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/dcc341a806ca415d7560d057f710798.png\" alt=\"\" class=\"wp-image-2656\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/dcc341a806ca415d7560d057f710798.png 782w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/dcc341a806ca415d7560d057f710798-300x135.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/dcc341a806ca415d7560d057f710798-768x345.png 768w\" sizes=\"(max-width: 782px) 100vw, 782px\" \/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5728lab0\u4e2dQuery\u4f20\u5165\u4e86\u4e24\u4e2a\u53c2\u6570\u3002\u524d\u8005\u4e3a\u6211\u4eec\u8981\u6267\u884c\u7684SELECT\u67e5\u8be2SQL\u8bed\u53e5\u3002\u540e\u8005\u5219\u4e3a\u4e00\u4e2astring\u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<p>\u800c\u8fd9\u4e2alineId\u4f1a\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165SQL\u8bed\u53e5\u4e2d\u7684&#8221;<em>AND line_id =?<\/em> &#8220;\u4e2d\uff0c\u76f8\u5f53\u4e8e\u662f&#8221;<em>AND line_id=lineId<\/em>\u201c.<\/p>\n\n\n\n<p>\u4f46\u6211\u4eec\u6d4b\u8bd5\u603b\u4e0d\u80fd\u4e5f\u76f4\u63a5\u7528lineId\uff0c\u6211\u4eec\u5f97\u81ea\u5df1\u6307\u5b9alineId=xxxxx\u3002\u4e0d\u8fc7\u8fd9\u4e2alineId&#8230;\u6ca1\u8bf4\u660e\u662f\u4ec0\u4e48\uff0c\u53ea\u77e5\u9053\u5b83\u53ef\u80fd\u662fxx\u7ebf\u8def\u7684id\u3002\u4f46\u662f\u8fd9\u4e2aid\u5230\u5e95\u662f\u4ec0\u4e48\u683c\u5f0f\uff0c\u65e2\u6ca1\u6253\u6ce8\u91ca\u4e5f\u6ca1\u6709\u8bf4\u660e\u3002\u90a3\u53ea\u80fd\u7ffb\u7ffb\u4ee3\u7801\u770b\u770b\u662f\u5565\u610f\u601d\u3002\u6211\u4eec\u5148\u770b\u770b\u5b83\u7684\u5b9a\u4e49<\/p>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"627\" height=\"264\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/b40138723d4beda89d4c900f04b46f9.png\" alt=\"\" class=\"wp-image-2657\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/b40138723d4beda89d4c900f04b46f9.png 627w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/b40138723d4beda89d4c900f04b46f9-300x126.png 300w\" sizes=\"(max-width: 627px) 100vw, 627px\" \/><\/figure>\n\n\n\n<p>\u8fd8\u662f\u6ca1\u8bf4lineId\u662f\u4ec0\u4e48\uff0c\u4f46\u6211\u4eec\u4ece\u8fd9\u4e2a\u51fd\u6570\u5927\u6982\u80fd\u63a8\u65ad\u51fa\uff1aGetRidership( )\u63a5\u6536string\u7c7b\u578b\u7684 lineId\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2aint\u7c7b\u578b\u7684\u5207\u7247\u548cerror\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5728\u6587\u4ef6\u4e2d\u641c\u7d22lineId\u8bd5\u8bd5\u3002\u6b64\u65f6\u5728ridersihp_db_test\u4e2d\u6211\u4eec\u627e\u5230\u4e86lineIds<\/p>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"809\" height=\"212\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/7d6861b87410519677c7740773f280b.png\" alt=\"\" class=\"wp-image-2658\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/7d6861b87410519677c7740773f280b.png 809w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/7d6861b87410519677c7740773f280b-300x79.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/7d6861b87410519677c7740773f280b-768x201.png 768w\" sizes=\"(max-width: 809px) 100vw, 809px\" \/><\/figure>\n\n\n\n<p>\u8fd8\u662f\u6ca1\u8bf4\u5b83\u662f\u5e72\u4ec0\u4e48\u7684\uff0c\u4f46\u6211\u4eec\u77e5\u9053\u4e86lineId\u5e94\u8be5\u548c\u8fd9\u56db\u79cd\u989c\u8272\u6709\u5173\u3002\u6211\u4eec\u63a8\u6d4blineId\u5e94\u8be5\u5c31\u662fxxx\u5730\u94c1\u7ebf\u8def\u6240\u4ee3\u8868\u7684\u989c\u8272\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u5b9e\u9a8c\u6b65\u9aa4<\/p>\n<cite><em>navicat\u6253\u5f00\u6570\u636e\u5e93\u6587\u4ef6mbta.sqlite<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e3a\u4e86\u9a8c\u8bc1lineId\u548c\u989c\u8272\u6709\u5173\uff0c\u6211\u4eec\u67e5\u770b\u4e00\u4e0b\u6570\u636e\u5e93\u7ed3\u6784\u3002\u8fd9\u91cc\u4f7f\u7528navicat\u6253\u5f00mbta.sqlite\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"250\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/fb587c63f7115c4400e7eab14463653-1024x250.png\" alt=\"\" class=\"wp-image-2659\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/fb587c63f7115c4400e7eab14463653-1024x250.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/fb587c63f7115c4400e7eab14463653-300x73.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/fb587c63f7115c4400e7eab14463653-768x187.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/fb587c63f7115c4400e7eab14463653.png 1147w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u770b\u5230\u6709\u4e2alines\uff0c\u8fd8\u6709\u4e2arail_ridership\uff0c\u90a3\u4e48\u4f1a\u4e0d\u4f1alineId\u8868\u793a\u7684\u662f\u4e0d\u540c\u5730\u94c1\u7ebf\u8def\u6240\u8868\u793a\u7684\u989c\u8272\u5462\uff1f\u4f46\u54b1\u5bf9\u6ce2\u58eb\u987f\u4e5f\u6ca1\u4ec0\u4e48\u4e86\u89e3\uff0c\u6ce2\u58eb\u987f\u7684\u5730\u94c1\u6709\u51e0\u53f7\u7ebf\uff0c\u4e0d\u77e5\u9053\uff1bxx\u53f7\u7ebf\u7528\u4ec0\u4e48\u989c\u8272\u8868\u793a\uff0c\u4e0d\u77e5\u9053\u3002\u4e0d\u8fc7\u4e0d\u77e5\u9053\u4e5f\u4e0d\u91cd\u8981\uff0c\u6211\u4eec\u6253\u5f00lines\u770b\u770b<\/p>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"235\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6de98721986491a29666973cdd78dd9.png\" alt=\"\" class=\"wp-image-2660\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6de98721986491a29666973cdd78dd9.png 924w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6de98721986491a29666973cdd78dd9-300x76.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6de98721986491a29666973cdd78dd9-768x195.png 768w\" sizes=\"(max-width: 924px) 100vw, 924px\" \/><\/figure>\n\n\n\n<p>\u5f88\u660e\u663e\u4e86\uff0cline_id\u5c31\u5e94\u8be5\u8868\u793a\u7684\u662fxx\u53f7\u7ebf\uff0c\u5373\u201cx\u53f7\u7ebf\u7684id\u201d\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u505a\u8fd9\u6b65\u53ea\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u4e86\u89e3\u81ea\u5df1\u8fd9\u6b21\u5b9e\u9a8c\u5230\u5e95\u662f\u5728\u5e72\u4ec0\u4e48\uff0c\u65b9\u4fbf\u6211\u4eec\u540e\u9762\u7f16\u5199Handlers\u7684\u5177\u4f53\u51fd\u6570\u3002<\/cite><\/blockquote>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u5b9e\u9a8c\u6b65\u9aa4<\/p>\n<cite><em>\u8865\u5168\u6d4b\u8bd5\u4ee3\u7801<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u90a3\u6211\u4eec\u76f4\u63a5\u5047\u8bbe\u8981\u67e5\u8be2\u201cred line\u201d\u8fd9\u6761\u7ebf\u8def\u7684\u4e58\u5ba2\u91cf\u3002\u90a3\u4e48\u628alab0\u4e2d\u4ee3\u7801\u590d\u5236\u8fc7\u6765\uff0c\u518d\u628alineId\u6539\u6210\u201cred\u201d\u8bd5\u8bd5\uff0c\u80fd\u83b7\u53d6\u5230\u6570\u636e\u5c31\u8bf4\u660e\u8fde\u63a5\u662f\u6210\u529f\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport (\n\t\"database\/sql\"\n\t\"fmt\"\n\t\"log\"\n\n\t_ \"github.com\/mattn\/go-sqlite3\"\n)\n\nfunc main() {\n\tdb, err := sql.Open(\"sqlite3\", \"c:\/Users\/LENOVO\/Desktop\/template\/testgo\/mbta.sqlite\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer db.Close()\n\tquery := `\n\t\tSELECT SUM(total_ons)\n\t\tFROM rail_ridership\n\t\tWHERE season = 'Fall 2017'\n\t\t\tAND time_period_id NOT IN ('time_period_10', 'time_period_11')\n\t\t\tAND line_id = ?\n\t\tGROUP BY time_period_id\n\t\tORDER BY time_period_id;\n\t`\n\trows, err := db.Query(query, \"green\")\n\tdefer rows.Close() <mark style=\"background-color:rgba(0, 0, 0, 0);color:#00ff2f\" class=\"has-inline-color\">\/\/\u522b\u5fd8\u4e86\u5173\u95ed\u8fde\u63a5<\/mark>\n\tfmt.Print(rows)\n}\n<\/code><\/pre>\n\n\n\n<p>\u5728fmt.Print(rows)\u90a3\u6253\u4e2a\u65ad\u70b9\uff0c\u65b9\u4fbf\u6211\u4eec\u67e5\u770b\u53d8\u91cf\u7684\u60c5\u51b5\u3002\u8c03\u8bd5\u4e00\u4e0b\uff0c\u5f97\u5230\u53d8\u91cf\u4fe1\u606f<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"339\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6399bc0a7b51532c73e77f031c9be70-1024x339.png\" alt=\"\" class=\"wp-image-2661\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6399bc0a7b51532c73e77f031c9be70-1024x339.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6399bc0a7b51532c73e77f031c9be70-300x99.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6399bc0a7b51532c73e77f031c9be70-768x255.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6399bc0a7b51532c73e77f031c9be70-1536x509.png 1536w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/10\/6399bc0a7b51532c73e77f031c9be70.png 1801w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>error\u4e3anil\uff0c\u8bf4\u660e\u8fde\u63a5\u8fc7\u7a0b\u6ca1\u51fa\u73b0\u62a5\u9519\u3002rows\u4e5f\u4e0d\u4e3anil\uff0c\u8bf4\u660erows\u786e\u5b9e\u83b7\u53d6\u5230\u4e86\u6570\u636e\u5e93\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u9644\u5f55<\/p>\n<cite><em>\u62a5\u9519\u539f\u56e0<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5728Lab0\u201c\u8fde\u63a5\u81f3\u6570\u636e\u5e93\u201d\u524d\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n\n\n\n<ul>\n<li>\u4f60\u7535\u8111\u6709\u5b89\u88c5gcc\uff0ccmd\u8f93\u5165gcc -v\u80fd\u663e\u793a\u7248\u672c\u4fe1\u606f\u3002\n<ul>\n<li>\u8fd9\u662f\u56e0\u4e3asqlite\u672c\u8eab\u7684\u6e90\u4ee3\u7801\u662fc\u7f16\u5199\u7684\u3002\u6240\u4ee5\u8981\u548cgo\u4e00\u8d77\u7528\u7684\u8bdd\u9700\u8981<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u672c\u5730\u6709c\u8bed\u8a00\u7684\u7f16\u8bd1\u73af\u5883<\/mark>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>mbta.sqlite\u6709\u8bfb\u5199\u6743\u9650\u3002\n<ul>\n<li>\u7531\u4e8embta.sqlite\u8fd9\u4e2a\u6587\u4ef6\u662f\u4f60\u81ea\u5df1\u4e0b\u8f7d\u4e0b\u6765\u7684\u3002\u5982\u679c\u4f60\u7528\u7684\u662flinux\uff0c\u8be5\u6587\u4ef6\u5f88\u6709\u53ef\u80fd\u9ed8\u8ba4\u6ca1\u6709\u8bfb\u5199\u6743\u9650\uff0c\u5efa\u8bae\u7ed9mbta.sqlite\u6240\u5728\u7684\u6587\u4ef6\u5939\u76f4\u63a5chmod\u52a0\u4e0a\u6743\u9650\u3002\u5982\u679c\u7528\u7684\u662fwindows\uff0c\u53f3\u952embta.sqlite\u6253\u5f00\u5c5e\u6027\uff0c\u4f60\u5927\u6982\u7387\u4f1a\u53d1\u73b0\u8be5\u6587\u4ef6\u63d0\u793a\u5df2\u88ab\u9501\u5b9a\u3002\u89e3\u9664\u9501\u5b9a\u5373\u53ef\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8ewindows\uff0c\u4e0a\u9762\u8fd9\u4e2a\u64cd\u4f5c\u5982\u679c\u6700\u540e\u8fd8\u662f\u62ff\u4e0d\u5230\u6570\u636e\u5e93\u7684\u6570\u636e\uff0ccmd\u8f93\u5165<br><em>cacls&nbsp;c:\/xxx\/database&nbsp;\/e \/t \/g&nbsp;everyone:F<\/em> \u3002\u5c06\u6570\u636e\u5e93\u6240\u5728\u7684\u6587\u4ef6\u5939\u8bbe\u7f6e\u4e3a\u6240\u6709\u4eba\u53ef\u5199\u3002\u5e94\u8be5\u5c31\u80fd\u89e3\u51b3\u95ee\u9898\u4e86\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>\u5728\u6d4b\u8bd5\u7528\u7684main.go\u8c03\u8bd5\u7684\u65f6\u5019\uff0c\u8d77\u7801<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">err\u5fc5\u987b\u662fnil<\/mark>\u3002rows\u4e4b\u7c7b\u7684\u5f97\u6839\u636e\u4f60\u81ea\u5df1\u7f16\u5199\u7684SQL\u8bed\u53e5\u6765\u770b\uff0c\u5982\u679c\u662f\u6309Lab0\u7ed9\u7684\u5b9e\u9a8c\u4ee3\u7801\uff0c\u6700\u540e<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">rows\u4e0d\u80fd\u662fnil<\/mark>\u3002\u5982\u679crows\u662fnil\u7684\u8bdd\u53ea\u80fd\u6839\u636eerror\u7684\u4fe1\u606f\u81ea\u5df1\u6162\u6162\u67e5\u62a5\u9519\u539f\u56e0\u4e86\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u591a\u6253\u65ad\u70b9\u591a\u8c03\u8bd5\uff0c\u7406\u89e3\u4ee3\u7801\u540e\u5728\u51e0\u4e2ago\u6587\u4ef6\u91cc\u627e\u53ef\u80fd\u4f1a\u51fa\u9519\u7684\u5730\u65b9\u6253\u4e0a\u65ad\u70b9\u3002\u6211\u81ea\u5df1\u5149\u662f\u8fde\u63a5\u6570\u636e\u5e93\u8fd9\u5757\u6253\u65ad\u70b9+\u8c03\u8bd5\u5c31\u82b1\u4e86\u4e00\u4e2a\u4e0b\u5348\u3002<\/cite><\/blockquote>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lab0\u5b9e\u9a8c\u8bb0\u5f55\uff1a\u8fde\u63a5sqlite\u6570\u636e\u5e93<\/p>\n","protected":false},"author":1,"featured_media":2650,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[44,33],"tags":[34,80],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2649"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2649"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2649\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2650"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}