Code Monkey home page Code Monkey logo

go-scru128's Introduction

SCRU128: Sortable, Clock and Random number-based Unique identifier

GitHub tag License

SCRU128 ID is yet another attempt to supersede UUID for the users who need decentralized, globally unique time-ordered identifiers. SCRU128 is inspired by ULID and KSUID and has the following features:

  • 128-bit unsigned integer type
  • Sortable by generation time (as integer and as text)
  • 25-digit case-insensitive textual representation (Base36)
  • 48-bit millisecond Unix timestamp that ensures useful life until year 10889
  • Up to 281 trillion time-ordered but unpredictable unique IDs per millisecond
  • 80-bit three-layer randomness for global uniqueness
import "github.com/scru128/go-scru128/v3"

// generate a new identifier object
x := scru128.New()
fmt.Println(x)    // e.g., "036z951mhjikzik2gsl81gr7l"
fmt.Println(x[:]) // as a 128-bit unsigned integer in big-endian byte array

// generate a textual representation directly
fmt.Println(scru128.NewString()) // e.g., "036z951mhzx67t63mq9xe6q0j"

See SCRU128 Specification for details.

License

Licensed under the Apache License, Version 2.0.

See also

go-scru128's People

Contributors

liosk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hitoshi44

go-scru128's Issues

Let all functions return `error`, instead of `panic`ing ?

Hello! I read your tweet-tree on UUID draft working, and I am exited to explore this repository!

In Golang, it's more popular to return error than panicing, especially for a large application.
So it seems better to let functions which may panic return error.

If you confirm this issue is actually meaningful, please check a PR which I send later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.