Comments (3)
+1,只能改成sql.NullTime
from go-zero.
如果有问题,最好能给个测试代码哈
from go-zero.
表结构:
CREATE TABLE `userinfo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uuid` varchar(64) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`registertime` datetime DEFAULT NULL,
`updatetime` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
insert into userinfo(uuid, name, email, password, created_at, updatetime) values ('1', 'sky', '[email protected]', '1', now(), now());
生成model
goctl model mysql datasource -url="web:muchinfo@tcp(127.0.0.1:3406)/web" -table="userinfo" -dir ./model
main.go文件
package main
import (
"fmt"
"sqltest/model"
"github.com/tal-tech/go-zero/core/stores/sqlx"
)
func main() {
userModel := model.NewUserinfoModel(sqlx.NewMysql("web:muchinfo@tcp(127.0.0.1:3406)/web?charset=utf8&parseTime=true&loc=Local"))
var id int64 = 1
userinfo, err := userModel.FindOne(id)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(*userinfo)
}
运行:
sql: Scan error on column index 5, name "registertime": unsupported Scan, storing driver.Value type <nil> into type *time.Time
from go-zero.
Related Issues (20)
- Gateway NewRequestParser json.NewDecoder map result in loss of numerical precision
- The tokenlimit with redis may work incorrectly due to network latency HOT 4
- gateway how to config cors function
- grpc error management like kratos error generator HOT 3
- Add a flag to whether to generate pb file HOT 1
- API Import generate questions HOT 6
- Need a customized.tpl file which includes all the template Execute variables. HOT 1
- I want to print log to file. But I already want to see it in console. HOT 6
- Any plan to support rocketmq? HOT 2
- Use gateway server.AddRoute(), The limit(MaxConns) of this route does not take effect HOT 3
- how to exec my own middleware before build-in jwt? HOT 1
- A RPC service generated by multiple proto files? HOT 3
- How to make gracefulStop waiting? HOT 8
- 'circuit breaker is open','last resolver error: produced zero addresses' HOT 3
- Suggest to add option to disable parameter validation HOT 1
- I've got a problem when I call httpx.Parse() HOT 7
- How to set the part of request params nil ? HOT 1
- Error: sh: goctl-swagger: command not found HOT 1
- How to report trace data to the Monitor of jaeger?
- bug on sql concatenation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-zero.