guid

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreationStrategy

type CreationStrategy string

CreationStrategy enumerates the values that are supported for populating the bits of a new Guid.

const (
	CreationStrategyVersion1 CreationStrategy = "version1"
	CreationStrategyVersion2 CreationStrategy = "version2"
	CreationStrategyVersion3 CreationStrategy = "version3"
	CreationStrategyVersion4 CreationStrategy = "version4"
	CreationStrategyVersion5 CreationStrategy = "version5"
)

These constants define the possible creation strategies available via this implementation of Guid.

type Format

type Format string

Format enumerates the values that are supported by Parse and Format

const (
	FormatB       Format = "B" // {00000000-0000-0000-0000-000000000000}
	FormatD       Format = "D" // 00000000-0000-0000-0000-000000000000
	FormatN       Format = "N" // 00000000000000000000000000000000
	FormatP       Format = "P" // (00000000-0000-0000-0000-000000000000)
	FormatX       Format = "X" // {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
	FormatDefault Format = FormatD
)

These constants define the possible string formats available via this implementation of Guid.

type GUID

type GUID struct {
	// contains filtered or unexported fields
}

GUID is a unique identifier designed to virtually guarantee non-conflict between values generated across a distributed system.

func Empty

func Empty() GUID

Empty returns a copy of the default and empty GUID.

func NewGUID

func NewGUID() GUID

NewGUID generates and returns a new globally unique identifier

func NewGUIDs

func NewGUIDs(strategy CreationStrategy) (GUID, error)

NewGUIDs generates and returns a new globally unique identifier that conforms to the given strategy.

func Parse

func Parse(value string) (GUID, error)

Parse instantiates a GUID from a text representation of the same GUID. This is the inverse of function family String()

func (GUID) MarshalJSON

func (guid GUID) MarshalJSON() (marshaled []byte, err error)

MarshalJSON writes a GUID as a JSON string.

func (GUID) String

func (guid GUID) String() string

String returns a text representation of a GUID in the default format.

func (GUID) Stringf

func (guid GUID) Stringf(format Format) string

Stringf returns a text representation of a GUID that conforms to the specified format. If an unrecognized format is provided, the empty string is returned.

func (*GUID) UnmarshalJSON

func (guid *GUID) UnmarshalJSON(marshaled []byte) (err error)

UnmarshalJSON parses a GUID from a JSON string token.

func (GUID) Version

func (guid GUID) Version() uint

Version reads a GUID to parse which mechanism of generating GUIDS was employed. Values returned here are documented in rfc4122.txt.

Jump to

Keyboard shortcuts

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