You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
498 B
Go
27 lines
498 B
Go
9 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"database/sql/driver"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
// nullTime allows timestamps to be NULL
|
||
|
type nullTime struct {
|
||
|
Time time.Time
|
||
|
Valid bool // Valid is true if Time is not NULL
|
||
|
}
|
||
|
|
||
|
// Scan implements the Scanner interface.
|
||
|
func (nt *nullTime) Scan(value interface{}) error {
|
||
|
nt.Time, nt.Valid = value.(time.Time)
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// Value implements the driver Valuer interface.
|
||
|
func (nt nullTime) Value() (driver.Value, error) {
|
||
|
if !nt.Valid {
|
||
|
return nil, nil
|
||
|
}
|
||
|
return nt.Time, nil
|
||
|
}
|