null is a Go library that provides reasonable handling of nullable values for SQL and JSON operations.
The library solves the problem of working with nullable database and JSON values by offering type-safe wrappers around Go's primitive types. Each wrapper type implements the necessary interfaces for database operations and JSON marshaling, distinguishing between truly null values and empty or zero values. Types only marshal to JSON null when they represent actual null input, and all types implement sql.Scanner and driver.Valuer so they can be used as drop-in replacements for Go's built-in sql.NullXXX types.
The tool suits projects that need to distinguish between null and empty values when working with databases and JSON APIs. It provides nullable versions of standard Go types including strings, integers, floats, booleans, bytes, and time.Time. Developers should be aware that the library has a known limitation with JSON's omitempty struct tag, which will not correctly omit null or empty strings. The project migrated from gopkg.in versioning to Go modules, so users upgrading to version 8 and beyond should update their import paths accordingly.
Development activity shows consistent maintenance with attention to test coverage and documentation through GoDoc integration. The project maintains implementations across a comprehensive set of nullable type variants, suggesting deliberate scope management rather than feature sprawl.