NullString represents a string that may be null. NullString implements the [Scanner] interface so it can be used as a scan destination:
var s NullString err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s) ... if s.Valid { // use s.String } else { // NULL value } Copy
var s NullString err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s) ... if s.Valid { // use s.String } else { // NULL value }
Scan implements the [Scanner] interface.
Value implements the [driver.Valuer] interface.
Generated using TypeDoc
NullString represents a string that may be null. NullString implements the [Scanner] interface so it can be used as a scan destination: