Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrWrongVersion = errors.New("data: wrong version for Id")
)
Functions ¶
This section is empty.
Types ¶
type Id ¶
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 ¶
MustId panics if err if not nil. It returns id otherwise.
This can be used as a utility, for instance: id := MustId(NewId())
func ParseIdBytes ¶
ParseIdBytes attempts to parse b and return the Id parsed from it.
func (Id) MarshalJSON ¶
MarshalJSON is the json.Marshaler implementation that allows transparent marshaling throughout the application.
func (*Id) Scan ¶
Scan is the sql.Scanner implementation that allows retrieving an Id transparently from a sql database.
func (*Id) UnmarshalJSON ¶
UnmarshalJSON is the json.Unmarshaler implementation that allows for transparent unmarshaling throughtout the application.