shortuuid

package module
v0.0.0-...-fac27f6 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2015 License: MIT Imports: 6 Imported by: 0

README

shortuuid.go

shortuuid is a simple go library that generates concise, unambiguous, +URL-safe UUIDs.

It's inspired by shortuuid python library

Usage

package main

import (
    "fmt"
    "github.com/anarcher/shortuuid"
)

func main() {
    id := shortuuid.New()
   fmt.Println(id)
}

$go run main.go
wusrj4VHumEALr4mQjArnj
$go run main.go
YTPp9cZDECzweSyywSespm

Documentation

Index

Constants

View Source
const (
	DEFAULT_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ShortUUID

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

func New

func New() *ShortUUID

func NewWithAlphabet

func NewWithAlphabet(alphabet string) *ShortUUID

func (*ShortUUID) Decode

func (s *ShortUUID) Decode(input string) (uuid.UUID, error)

func (*ShortUUID) Encode

func (s *ShortUUID) Encode(uuid uuid.UUID) string

Encodes a UUID into a string (LSB first) according to the alphabet If leftmost (MSB) bits 0, string might be shorter

func (*ShortUUID) SetAlphabet

func (s *ShortUUID) SetAlphabet(alphabet string)

func (ShortUUID) String

func (s ShortUUID) String() string

func (*ShortUUID) UUID

func (s *ShortUUID) UUID(name string) string

type StringSet

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

func NewStringSet

func NewStringSet() *StringSet

func (*StringSet) Add

func (set *StringSet) Add(i string) bool

func (*StringSet) Contains

func (set *StringSet) Contains(i string) bool

func (*StringSet) Index

func (set *StringSet) Index(c string) int

func (*StringSet) ItemByIndex

func (set *StringSet) ItemByIndex(idx int) string

func (*StringSet) Len

func (set *StringSet) Len() int

func (*StringSet) Remove

func (set *StringSet) Remove(i string)

func (*StringSet) Sort

func (set *StringSet) Sort()

func (*StringSet) String

func (set *StringSet) String() string

Jump to

Keyboard shortcuts

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