smartid

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 3 Imported by: 0

README

smartid CI Go Report Card

The smartid package generates URL and filename safe 160 bit (20 byte) random IDs using URL and Filename safe alphabet [RFC].

Safe and fast. Based on crypto/rand. No external depdendencies required.

Documentation

GoDoc

Full go doc: https://pkg.go.dev/github.com/dmasior/smartid

install
go get github.com/dmasior/smartid
usage
import
import "github.com/dmasior/smartid"
New()
id, err := smartid.New()
if err != nil {
    // handle err
}

fmt.Println(id.String())

// print example: 9z4Q7WaUmzQetcj8CCWcKITTg3w
MustNew()
id := smartid.MustNew()

fmt.Println(id.String())

// print example: oJemcLfABvB4buGAdXiKd2TJFiE
MustNewString()
id := smartid.MustNewString()

fmt.Println(id)

// print example: KkdpotMGjcJoBFrDtltifuIDw38

Documentation

Overview

Example
id := MustNew()

fmt.Println(id.String())

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustNewString

func MustNewString() string

MustNewString creates new SmartID and returns it as string or panics. MustNewString is equivalent of:

smartid.Must(smartid.New()).String()

Types

type SmartID

type SmartID [27]byte

A SmartID has size of 27 bytes which is encoded size of a 160 bit (20 byte) random identifier.

func Must

func Must(ID SmartID, err error) SmartID

Must returns SmartID if err is nil and panics otherwise.

func MustNew

func MustNew() SmartID

MustNew creates new SmartID or panics. MustNew is equivalent of:

smartid.Must(smartid.New())

func New

func New() (SmartID, error)

New creates new SmartID.

func (SmartID) String

func (s SmartID) String() string

String returns string from SmartID

Jump to

Keyboard shortcuts

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