types

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box added in v0.0.7

type Box struct {
	X1 int
	X2 int
	Y1 int
	Y2 int
}

Box contains the two opposing corners of a geometric box, matching Postgres' box type.

Please note that Postgresql will always place the upper right corner first - so X1/Y1 might be X2/Y2 when you read it back out - but the semantics are correct.

func (*Box) Scan added in v0.0.7

func (b *Box) Scan(src interface{}) error

Scan implements sql.Scan to enable gondulapi/db to read the SQL directly into the box.

func (Box) Value added in v0.0.7

func (b Box) Value() (driver.Value, error)

Value implements sql/driver's Value interface to provide implicit support for writing the value.

In other words: Scan() enables SELECT and Value() allows INSERT/UPDATE.

type IP

type IP struct {
	IP   net.IP
	Mask int
}

IP represent an IP and an optional netmask/size. It is provided because while net/IP provides much of what is needed for marshalling to/from text and json, it doesn't provide a convenient netmask. And it doesn't implement database/sql's Scanner either. This type implements both MarshalText/UnmarshalText and Scan(), and to top it off: String(). this should ensure maximum usability.

func (IP) MarshalText

func (i IP) MarshalText() ([]byte, error)

MarshalText returns a text version of an ip using String, it is used by various encoders, including the JSON encoder.

func (*IP) Scan

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

Scan is used by database/sql's Scan to parse bytes to an IP structure.

func (*IP) String

func (i *IP) String() string

String returns a ip address in string format, with an optional /mask if the IP has a non-zero mask.

func (*IP) UnmarshalText

func (i *IP) UnmarshalText(b []byte) error

UnmarshalText parses a byte string onto an IP structure. It is used by various encoders, including the JSON encoder.

func (IP) Value added in v0.0.2

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

Value implements sql/driver's Value interface to provide implicit support for writing the value.

Jump to

Keyboard shortcuts

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