Documentation
¶
Index ¶
- Constants
- Variables
- func Batch(uuids []UUID, size int, onBatch func(uuids []UUID) error) error
- func DefaultHWAddrFunc() (net.HardwareAddr, error)
- func Equal(u1 UUID, u2 UUID) bool
- type Generator
- type NullUUID
- type UUID
- func (u UUID) Bytes() []byte
- func (u UUID) MarshalBinary() (data []byte, err error)
- func (u *UUID) MarshalJSON() ([]byte, error)
- func (u UUID) MarshalText() (text []byte, err error)
- func (u *UUID) Scan(src any) error
- func (u *UUID) SetFromMSSQLBytes(data []byte) error
- func (u *UUID) SetVariant(v byte)
- func (u *UUID) SetVersion(v byte)
- func (u *UUID) String() string
- func (u *UUID) UnmarshalBinary(data []byte) error
- func (u *UUID) UnmarshalJSON(body []byte) error
- func (u *UUID) UnmarshalText(t []byte) (err error)
- func (u UUID) Value() (driver.Value, error)
- func (u UUID) Variant() byte
- func (u UUID) Version() byte
Constants ¶
const ( VariantNCS byte = iota VariantRFC4122 VariantMicrosoft VariantFuture )
UUID layout variants.
const CanonicalSize = 36
Size of a canonical representation of UUID in bytes.
const Size = 16
Size of a UUID in bytes.
const (
V4 byte
)
UUID versions
Variables ¶
var NilUUID = UUID{}
Nil is special form of UUID that is specified to have all 128 bits set to zero.
Functions ¶
func DefaultHWAddrFunc ¶
func DefaultHWAddrFunc() (net.HardwareAddr, error)
Returns hardware address.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Default generator implementation.
func NewRFC4122Generator ¶
func NewRFC4122Generator() *Generator
type NullUUID ¶
NullUUID can be used with the standard sql package to represent a UUID value that can be NULL in the database.
Contains a Valid parameter using to check if the UUID value is null or not.
func (*NullUUID) MarshalJSON ¶
Implements the json.Marshaler interface.
Marshal JSON value as string using the canonical format
func (*NullUUID) Scan ¶
Scan implements the sql.Scanner interface.
Used to read the value provided by the SQL server.
func (*NullUUID) UnmarshalJSON ¶
Implements the json.Unmarshaler interface.
Unmarshal JSON value from canonical format
type UUID ¶
UUID representation compliant with specification described in RFC 4122.
func FromBytes ¶
FromBytes returns UUID converted from raw byte slice input.
It will return error if the slice isn't 16 bytes long.
func FromBytesOrNil ¶
FromBytesOrNil returns UUID converted from raw byte slice input.
Same behavior as FromBytes, but returns a Nil UUID on error.
func FromString ¶
FromString returns UUID parsed from string input.
Input is expected in a form accepted by UnmarshalText.
func FromStringOrNil ¶
FromStringOrNil returns UUID parsed from string input.
Same behavior as FromString but returns a Nil UUID on error.
func (UUID) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*UUID) MarshalJSON ¶
Implements the json.Marshaler interface.
Marshal JSON value as string using the canonical format
func (UUID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
The encoding is the same as returned by String.
func (*UUID) Scan ¶
Scan implements the sql.Scanner interface with a solution specific for MSSQL.
A 16-byte slice is handled by UnmarshalBinary, while a longer byte slice or a string is handled by UnmarshalText.
func (*UUID) SetFromMSSQLBytes ¶
Set UUID from data fetched from a MSSQL Server as unique identifier.
SQL server stores UUID in a different way some conversion is required.
func (*UUID) String ¶
Returns canonical string representation of UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
func (*UUID) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
It will return error if the slice isn't 16 bytes long.
func (*UUID) UnmarshalJSON ¶
Implements the json.Unmarshaler interface.
Unmarshal JSON value from canonical format
func (*UUID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
Following format is supported "6ba7b810-9dad-11d1-80b4-00c04fd430c8",