{"id":439562,"date":"2021-04-14T11:44:57","date_gmt":"2021-04-14T03:44:57","guid":{"rendered":"http:\/\/4563.org\/?p=439562"},"modified":"2021-04-14T11:44:57","modified_gmt":"2021-04-14T03:44:57","slug":"gorm-%e6%89%ab%e6%8f%8f%e6%97%a5%e6%9c%9f%e8%8e%b7%e5%8f%96%e7%bb%93%e6%9e%9c%e4%b8%ba%e9%9b%b6%e5%80%bc","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=439562","title":{"rendered":"gorm \u626b\u63cf\u65e5\u671f\u83b7\u53d6\u7ed3\u679c\u4e3a\u96f6\u503c"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  gorm \u626b\u63cf\u65e5\u671f\u83b7\u53d6\u7ed3\u679c\u4e3a\u96f6\u503c               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : marcosteam <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7a0b\u5e8f\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code>type CheckInStatus struct {  ExpTime time.Time  LastCheckTime time.Time  TransferEnable int64 } ... database.Db.  Debug().  Table(\"users\").  Select(\"expire_time,last_check_in_time,transfer_enable\").  Where(\"id = ?\",uid).  Scan(&amp;checkInStatus)  <\/code><\/pre>\n<p>\u626b\u63cf\u51fa\u6765\u7684\u7ed3\u679c\u662f<\/p>\n<pre><code>2021\/04\/04 20:52:49 0001-01-01 00:00:00 +0000 UTC 2021\/04\/04 20:52:49 0001-01-01 00:00:00 +0000 UTC 2021\/04\/04 20:52:49 257949696 <\/code><\/pre>\n<p>gorm \u6210\u529f\u83b7\u53d6\u5230\u4e86\u6570\u636e\uff0c\u4f46\u662f\u6ca1\u6709\u5c06\u65e5\u671f\u89e3\u6790\u4e3a\u6b63\u786e\u7684\u503c&#8230; \u5df2\u7ecf\u5728\u6570\u636e\u5e93\u8fde\u63a5 URL \u4e2d\u8bbe\u7f6e\u4e86 <code>&amp;parseTime=True&amp;loc=Local<\/code><\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5658751\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mogg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u540d\u5b57\u5bf9\u4e0d\u4e0a\uff0c\u8981\u4e48\u5728\u7ed3\u6784\u4f53\u91cc\u58f0\u660e\u5217\u540d\uff0c\u6bd4\u5982 ExpTime time.Time `gorm:&#8221;column:expire_time&#8221;`\uff0c\u8981\u4e48 select \u7684\u65f6\u5019\u7528\u4e00\u4e0b as\uff0cSelect(&#8220;expire_time as exp_time \u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5658752\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : toomlo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`golang<br \/>type TimeN struct {<br \/> time.Time<br \/>}<\/p>\n<p>type (t TimeN) String() string{<br \/> return t.Format(`2006-01-02 15:04:05`)<br \/>}<\/p>\n<p>type CheckInStatus struct {<br \/> ExpTime TimeN<br \/> LastCheckTime TimeN<br \/> TransferEnable int64<br \/>}<br \/>&#8220;`<\/p>\n<p>\u5982\u679c\u4f60\u9700\u8981\u5c06 CheckInStatus \u8fd9\u4e2a\u7ed3\u6784\u7684\u5b9e\u4f8b json \u683c\u5f0f\u5316\u7684\u8bdd \u8fd8\u9700\u8981\u91cd\u5199 Time \u7684 MarshalJSON \u548c UnmarshalJSON \u65b9\u6cd5                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5658753\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : marcosteam <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @mogg \u5df2\u7ecf\u89e3\u51b3\uff0c\u611f\u8c22\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>gorm \u626b\u63cf\u65e5\u671f\u83b7\u53d6\u7ed3\u679c\u4e3a\u96f6\u503c &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\/439562"}],"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=439562"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/439562\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=439562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=439562"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=439562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}