Skip to content

Latest commit

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

cuid

Collision-resistant hashes for the cloud, in Go.

The cuid package provides collision-resistant ids optimized for horizontal scaling and sequential lookup performance. This README file is just going to cover the basics and the Go-specific implementation details.

Please refer to the main project site for the full rationale behind CUIDs.

Sample CUID

ch72gsb320000udocl363eofy

Sample CUID Slug

ew0k9fwpl

Installation

go get -u github.com/lucsky/cuid

Example usage

package main
import (
"crypto/rand""fmt""github.com/lucsky/cuid"
)
funcmain() {
// Generate pseudo-random CUIDfmt.Println(cuid.New())
// Generate slugfmt.Println(cuid.Slug())
// Generate cryptographic-random CUIDc, err:=cuid.NewCrypto(rand.Reader)
iferr!=nil {
fmt.Printf("%v", err)
return
}
fmt.Println(c)
}

Go package specific features

The Go cuid package provides APIs to specify a custom random source as well as a custom counter. A custom counter implementation could provide a centralized Redis base counter, for example.

Contributors

  • Luc Heinrich (@lucsky, author)
  • Thomas Hopkins (@hopkinsth)
  • fiatjaf
  • Marcus Dantas (@mpsdantas)
  • Oscar Forner Martinez (@maitesin)
  • Mike Frey (@mikefrey)
  • Andris Mednis (@andrismednis)

About

Collision-resistant hashes for the cloud, in Go

Resources

Stars

142 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages