Help us shape the future of Go! Take the 2026 Go Developer Survey

cuid

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2014 License: MIT Imports: 7 Imported by: 149

README

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 behine CUIDs.

Sample CUID

ch72gsb320000udocl363eofy

Installation

HEAD:

go get github.com/lucsky/cuid

v1.0.0:

go get gopkg.in/lucsky/cuid.v1

Example usage

package main

import fmt
import "gopkg.in/lucsky/cuid.v1"

func main() {
    fmt.Println(cuid.New())
}

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.

Documentation

Index

Constants

View Source
const (
	BLOCK_SIZE = 4
	BASE       = 36
)

Variables

This section is empty.

Functions

func New

func New() string

func SetCounter

func SetCounter(cnt Counter)

func SetRandom

func SetRandom(rnd *rand.Rand)

func SetRandomSource

func SetRandomSource(src rand.Source)

Types

type Counter

type Counter interface {
	Next() int32
}

type DefaultCounter

type DefaultCounter struct {
	// contains filtered or unexported fields
}

func (*DefaultCounter) Next

func (c *DefaultCounter) Next() int32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL