AlgoMaster Logo

Null Handling (sql.Null*)

High Priority11 min readUpdated June 6, 2026

SQL columns can be NULL, but Go primitives like string, int64, and float64 cannot. Scanning a NULL straight into a plain string returns a runtime error from database/sql. This chapter covers the three ways Go gives you to represent a nullable column: the legacy sql.NullString family, the Go 1.22 generic sql.Null[T], and plain pointers, with guidance on which to pick for which job.

Premium Content

Subscribe to unlock full access to this content and more premium articles.