Documentation ¶
Overview ¶
Package objectid contains an implementation of a BSON objectID type functions to create objectIDs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHex = errors.New("the provided hex string is not a valid ObjectID")
ErrInvalidHex indicates that a hex string cannot be converted to an ObjectID.
Functions ¶
This section is empty.
Types ¶
type ObjectID ¶
type ObjectID [12]byte
ObjectID is the BSON ObjectID type.
var NilObjectID ObjectID
NilObjectID is the zero value for ObjectID.
func FromHex ¶ added in v0.0.2
FromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.
func (ObjectID) MarshalJSON ¶ added in v0.0.16
MarshalJSON returns the ObjectID as a string
func (*ObjectID) UnmarshalJSON ¶
UnmarshalJSON populates the byte slice with the ObjectID. If the byte slice is 64 bytes long, it will be populated with the hex representation of the ObjectID. If the byte slice is twelve bytes long, it will be populated with the BSON representation of the ObjectID. Otherwise, it will return an error.