types

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package types contain misc data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes16

type Bytes16 [16]byte

Bytes16 is an alias for [16]byte, Bytes16 implements Marshal and Unmarshal.

func ParseBytes16

func ParseBytes16(buf []byte) (b Bytes16, err error)

ParseBytes is like Parse, except it parses a byte slice instead of a string.

func (Bytes16) Compare

func (b Bytes16) Compare(other Bytes16) int

func (Bytes16) Equal

func (b Bytes16) Equal(other Bytes16) bool

func (*Bytes16) FromHexString

func (b *Bytes16) FromHexString(buf []byte) error

func (Bytes16) Marshal

func (b Bytes16) Marshal() ([]byte, error)

Marshal obj into your JSON variable.

func (Bytes16) MarshalJSON

func (b Bytes16) MarshalJSON() ([]byte, error)

func (Bytes16) MarshalTo

func (b Bytes16) MarshalTo(buf []byte) (n int, err error)

func (*Bytes16) Scan

func (b *Bytes16) Scan(src any) error

Scan implements the Scanner interface.

func (*Bytes16) Size

func (b *Bytes16) Size() int

func (Bytes16) ToHexString

func (b Bytes16) ToHexString() string

func (*Bytes16) Unmarshal

func (b *Bytes16) Unmarshal(buf []byte) error

Unmarshal your JSON variable into dest.

func (*Bytes16) UnmarshalJSON

func (b *Bytes16) UnmarshalJSON(from []byte) error

func (Bytes16) Value

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

Value implements the driver Valuer interface.

type Decimal

type Decimal struct {
	decimal.Big
}

Decimal is a DECIMAL in sql. Its zero value is valid for use with both Value and Scan.

Although decimal can represent NaN and Infinity it will return an error if an attempt to store these values in the database is made.

Because it cannot be nil, when Big is nil Value() will return "0" It will error if an attempt to Scan() a "null" value into it.

func NewDecimal

func NewDecimal(d *decimal.Big) (num Decimal)

NewDecimal creates a new decimal from a decimal

func (*Decimal) Scan

func (d *Decimal) Scan(val any) (err error)

Scan implements sql.Scanner.

func (Decimal) Value

func (d Decimal) Value() (driver.Value, error)

Value implements driver.Valuer.

type JSON

type JSON json.RawMessage

JSON is an alias for json.RawMessage, which is a []byte underneath. JSON implements Marshal and Unmarshal.

func (*JSON) Marshal

func (j *JSON) Marshal(obj any) (err error)

Marshal obj into your JSON variable.

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON returns j as the JSON encoding of j.

func (*JSON) Scan

func (j *JSON) Scan(src any) error

Scan stores the src in *j.

func (JSON) String

func (j JSON) String() string

String output your JSON.

func (JSON) Unmarshal

func (j JSON) Unmarshal(dest any) error

Unmarshal your JSON variable into dest.

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *j to a copy of data.

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value returns j as a value. Unmarshal into RawMessage for validation.

type JSONTime

type JSONTime time.Time

func (JSONTime) MarshalJSON

func (dttm JSONTime) MarshalJSON() ([]byte, error)

func (*JSONTime) UnmarshalJSON

func (dttm *JSONTime) UnmarshalJSON(b []byte) error

type NullDecimal

type NullDecimal struct {
	*decimal.Big
}

NullDecimal is the same as Decimal, but allows the Big pointer to be nil. See docmentation for Decimal for more details.

When going into a database, if Big is nil it's value will be "null".

func NewNullDecimal

func NewNullDecimal(d *decimal.Big) NullDecimal

NewNullDecimal creates a new null decimal from a decimal

func (*NullDecimal) Scan

func (n *NullDecimal) Scan(val any) error

Scan implements sql.Scanner.

func (NullDecimal) Value

func (n NullDecimal) Value() (driver.Value, error)

Value implements driver.Valuer.

type UUID

type UUID [16]byte

func NewUUID

func NewUUID() (u UUID)

func (*UUID) Clear

func (u *UUID) Clear() *UUID

func (UUID) Compare

func (u UUID) Compare(other UUID) int

func (UUID) Equal

func (u UUID) Equal(other UUID) bool

func (UUID) IsZero

func (u UUID) IsZero() bool

func (UUID) Marshal

func (u UUID) Marshal() ([]byte, error)

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

func (UUID) MarshalTo

func (u UUID) MarshalTo(buf []byte) (n int, err error)

func (*UUID) Random

func (u *UUID) Random() *UUID

func (*UUID) Scan

func (u *UUID) Scan(src any) error

Scan implements the Scanner interface.

func (*UUID) Size

func (u *UUID) Size() int

func (UUID) ToHexString

func (u UUID) ToHexString() string

func (*UUID) UUIDFromHexString

func (u *UUID) UUIDFromHexString(buf []byte) error

func (*UUID) Unmarshal

func (u *UUID) Unmarshal(buf []byte) error

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(from []byte) error

func (UUID) Value

func (u UUID) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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