Categorygithub.com/jimdn/objectid
modulepackage
1.0.0
Repository: https://github.com/jimdn/objectid.git
Documentation: pkg.go.dev

# README

jimdn/objectid

A package to generate a 12-bytes unique object identifier.

MIT License Go Report Card

Installation

Use go get.

go get github.com/jimdn/objectid

Then import the package into your own code.

import "github.com/jimdn/objectid"

Example

package main

import (
	"fmt"
	"github.com/jimdn/objectid"
)

func main() {
	objIdStr := objectid.New().String()
	fmt.Printf("%s\n", objIdStr)

	objId, _ := objectid.Parse(objIdStr)
	fmt.Printf("%d-%d-%d-%d\n", objId.Timestamp(), objId.Machine(), objId.Pid(), objId.Increment())
}

# Functions

News generates new ObjectID with a unique value.
Parses a string and creates a new ObjectId.

# Structs

A globally unique identifier for objects.