On this page
Package typeinfo provides a structured PostgreSQL type representation, parsing raw type strings into base plus parameters and rebuilding SQL type strings.
#internal/typeinfo
#internal/typeinfo
Package typeinfo provides structured PostgreSQL type representation. It parses raw type strings (from TOML schemas, format_type() output, etc.) into a normalized struct with separated base type and parameters, and can reconstruct the SQL type string from the struct.
#Params
type Params structParams holds parsed type parameters. For known types, named fields are populated; for unknown/extension types, only RawModifier is set.
#Type
type Type structType represents a parsed PostgreSQL type with its canonical base name and optional parameters.
#Parse
func Parse(raw string) TypeParse parses a raw PostgreSQL type string into a structured Type. It normalizes aliases, extracts parameters, and handles multi-word types with interior parameters (e.g., "timestamp(3) with time zone"). DomainName is NEVER set by Parse.
#Reconstruct
func Reconstruct(t Type) stringReconstruct rebuilds a SQL type string from a Type struct. If DomainName is set, it is returned directly (domain-backed columns use the domain name in DDL). Otherwise, the type is reconstructed from Base and Params.
#T
func T(base string) TypeT is a concise constructor for test literals. It returns Type{Base: base} with all params at zero values.
#MustParse
func MustParse(raw string) TypeMustParse parses a raw type string and panics if the input is empty. Intended for test setup only.
#Type.Equal
func (t Type) Equal(other Type) boolEqual returns true if two Types have the same Base, DomainName, and Params (deep comparison of pointer fields).