var ErrInvalidHex … type ObjectID … var NilObjectID … // Hex returns the hex encoding of the ObjectID as a string. func (id ObjectID) Hex() string { … } func (id ObjectID) String() string { … } // IsZero returns true if id is the empty ObjectID. func (id ObjectID) IsZero() bool { … } // ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a // valid ObjectID. func ObjectIDFromHex(s string) (ObjectID, error) { … } // MarshalJSON returns the ObjectID as a string func (id ObjectID) MarshalJSON() ([]byte, error) { … } // UnmarshalJSON populates the byte slice with the ObjectID. If the byte slice is 24 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. This method also accepts empty strings and // decodes them as NilObjectID. For any other inputs, an error will be returned. func (id *ObjectID) UnmarshalJSON(b []byte) error { … }