pgtypes

package
v1.4.11 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 any) 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