| 
	go语言从PostgreSQL数据库读取数据,  
	timestamp类型的字段,直接读取后为2018-01-01T15:59:24Z 格式  
	date类型字段,直接读取为2018-01-01T00:00:00Z 格式 
	需要做一下处理  
	定义LocalTime、LocalDate结构体  
	实现MarshalJSON接口,格式化一下数据 
	type LocalTime time.Time 
	// MarshalJSON satify the json marshal interface 
	func (l LocalTime) MarshalJSON() ([]byte, error) { 
	    stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02 15:04:05")) 
	    return []byte(stamp), nil 
	} 
	type LocalDate time.Time 
	// MarshalJSON satify the json marshal interface 
	func (l LocalDate) MarshalJSON() ([]byte, error) { 
	    stamp := fmt.Sprintf("\"%s\"", time.Time(l).Format("2006-01-02")) 
	    return []byte(stamp), nil 
	} 
	在定义接收数据的结构体时,定义成员类型为LocalTime、LocalDate,可以根据需要格式化出数据 
	type LogInfo struct { 
	    ID         int       `form:"id" json:"id" gorm:"id"` 
	    LogName    string    `form:"log_name" json:"log_name" gorm:"column:log_name"` 
	    CreateTime LocalTime `form:"create_time" json:"create_time" gorm:"column:create_time"` 
	    CreateDate LocalDate `form:"create_date" json:"create_date" gorm:"column:create_date"` 
	} (责任编辑:IT) | 
