Categorygithub.com/gdbu/uuid
repositorypackage
0.1.0
Repository: https://github.com/gdbu/uuid.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

UUID

UUID is a unique user identifier generating library.

Features

  • Thread-safe
  • UUIDs carry a nano-precision timestamp of the generated time
  • Ability to create generators for sharding of thread-locking

Usage

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/gdbu/uuid"
)

func main() {
	// Generate user id
	userID := uuid.New()

	// You can print it as a string
	fmt.Println(userID.String())

	// Additionally, a pointer to a UUID is a stringer interface
	fmt.Println(&userID)

	// You can marshal it as JSON
	if bs, err := json.Marshal(userID); err != nil {
		log.Fatal("Error marshaling!", err)
	} else {
		fmt.Println("JSON bytes!", string(bs))
	}
}