go语言时间类型入库timestamp

1. mysql数据库字段类型timestamp

  `created_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP

2. model类型

type Books struct {

	CreatedAt  time.Time
	UpdatedAt  time.Time
}

3. 类型赋值

time.Now().UTC().Truncate(time.Microsecond)

猜你喜欢

转载自blog.csdn.net/qq960685827/article/details/123440943