objectid

package
v0.0.0-...-8b4400c Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 New

func New() ObjectID

New generates a new ObjectID.

func NewFromHex

func NewFromHex(s string) (ObjectID, error)

NewFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.

func NewFromTimestamp

func NewFromTimestamp(timestamp time.Time) ObjectID

NewFromTimestamp generates a new ObjectID based on the given time.

func (ObjectID) Hex

func (id ObjectID) Hex() string

Hex returns the hex encoding of the ObjectID as a string.

func (ObjectID) IsZero

func (id ObjectID) IsZero() bool

IsZero returns true if id is the empty ObjectID.

Jump to

Keyboard shortcuts

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