data

package
v0.0.0-...-bcf6333 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongVersion = errors.New("data: wrong version for Id")
)

Functions

This section is empty.

Types

type Id

type Id uuid.UUID

Id is the type that we are going to use as an identifier throughout the application.

For storing, for instance in a database, that code and the database will need to know that an Id is a Version 4 UUID. However, through the NewId() function and its methods, client code can think of the Id type as some opaque identifier.

func EmptyId

func EmptyId() Id

EmptyId returns an Id without any data in it. This can be used instead of nil to indicate a zero value.

func MustId

func MustId(id Id, err error) Id

MustId panics if err if not nil. It returns id otherwise.

This can be used as a utility, for instance: id := MustId(NewId())

func NewId

func NewId() (Id, error)

NewId returns a new Id or an error is one could not be created.

func ParseId

func ParseId(s string) (Id, error)

ParseId attempts to parse s and return the Id parsed from it.

func ParseIdBytes

func ParseIdBytes(b []byte) (Id, error)

ParseIdBytes attempts to parse b and return the Id parsed from it.

func (Id) Equal

func (id Id) Equal(other Id) bool

Equal returns whether or not id and other represent that same value.

func (Id) IsEmpty

func (id Id) IsEmpty() bool

IsEmpty returns whether or not id is an empty Id.

func (Id) MarshalJSON

func (id Id) MarshalJSON() ([]byte, error)

MarshalJSON is the json.Marshaler implementation that allows transparent marshaling throughout the application.

func (*Id) Scan

func (id *Id) Scan(src interface{}) error

Scan is the sql.Scanner implementation that allows retrieving an Id transparently from a sql database.

func (Id) String

func (id Id) String() string

String is the fmt.Stringer implementation.

func (*Id) UnmarshalJSON

func (id *Id) UnmarshalJSON(p []byte) error

UnmarshalJSON is the json.Unmarshaler implementation that allows for transparent unmarshaling throughtout the application.

func (Id) Value

func (id Id) Value() (driver.Value, error)

Value is the driver.Value implementation that allows storing an Id transparently in a sql database.

Directories

Path Synopsis
storage

Jump to

Keyboard shortcuts

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