pgtypes

package
v0.4.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pgtypes provides custom types for PostgreSQL database operations. It includes types for handling PostgreSQL-specific data types that need special conversion to/from Go types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interval

type Interval struct {
	// Duration is the Go time.Duration representation
	Duration time.Duration
	// Valid indicates whether the interval is NULL
	Valid bool
}

Interval represents a PostgreSQL INTERVAL type that maps to Go's time.Duration. This type implements sql.Scanner and driver.Valuer interfaces to allow seamless conversion between PostgreSQL INTERVAL and Go time.Duration.

func NewInterval

func NewInterval(d time.Duration) Interval

NewInterval creates a new Interval from a time.Duration

func NewNullInterval

func NewNullInterval() Interval

NewNullInterval creates a NULL interval

func ParseDuration

func ParseDuration(s string) (Interval, error)

ParseDuration parses a duration string (like "30m", "1h") and returns an Interval

func (*Interval) Scan

func (i *Interval) Scan(src interface{}) error

Scan implements the sql.Scanner interface to read PostgreSQL INTERVAL values

func (Interval) String

func (i Interval) String() string

String returns a human-readable representation of the interval

func (Interval) Value

func (i Interval) Value() (driver.Value, error)

Value implements the driver.Valuer interface to write PostgreSQL INTERVAL values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL