Created
August 21, 2018 05:05
-
-
Save plutov/7755871af7ac99b095e887ad55e0b28c to your computer and use it in GitHub Desktop.
working-with-db-time-in-go1.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nt mysql.NullTime | |
err := db.QueryRow("SELECT time FROM foo WHERE id = ?", id).Scan(&nt) | |
if nt.Valid { | |
// use nt.Time | |
} else { | |
// NULL value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment