Library to generate MongoDB objectID's
$ objectid -h
Usage of objectid:
-format string
format of objectid: hex, base64 (default "hex")
-from-time string
create a new objectid from a date time (RFC3339, $(date -I), $(date -Ihours), $(date -d -Iminutes), $(date -Iseconds)
-n int
number of objectid to generate (default 1)
-separator string
separator between objectids (default "\n")
-to-time string
convert objectid to time
$ objectid
6435f4800000000000000000$ objectid -format base64
ZiesvNpsbBz8QUGk$ objectid -n 3
6435f4800000000000000000
6435f4800000000000000001
6435f4800000000000000002$ objectid -from-time 2023-04-12
6435f4800000000000000000%$ objectid -to-time 6435f4800000000000000000
2023-04-12 00:00:00 +0000 UTCgo get -u github.com/Ajnasz/objectidimport "github.com/Ajnasz/objectid"
func main() {
oid := objectid.New()
fmt.Printf("%s", oid)
}go install github.com/Ajnasz/objectid/cmd/objectidor
make build
bin/objectid