types

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 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 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