Code Monkey home page Code Monkey logo

Comments (3)

daleyshek avatar daleyshek commented on May 13, 2024

+1,只能改成sql.NullTime

from go-zero.

kevwan avatar kevwan commented on May 13, 2024

如果有问题,最好能给个测试代码哈

from go-zero.

shenbaise9527 avatar shenbaise9527 commented on May 13, 2024

表结构:

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.