miniid

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 1 Imported by: 0

README

miniid

build-img pkg-img reportcard-img coverage-img version-img

miniid generates ID encoded in base62.

Features

  • Simple API.
  • Clean and tested code.
  • Dependency-free.

Install

Go version 1.20+

go get github.com/cristalhq/miniid

Example

gen := miniid.New(1200)

for i := 0; i < 10; i++ {
	fmt.Print(gen.Next(), " ")
}
fmt.Println()

// Output:
// JN JO JP JQ JR JS JT JU JV JW

Also see examples: example_test.go.

Documentation

See these docs.

License

MIT License.

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/cristalhq/miniid"
)

func main() {
	gen := miniid.New(1200)

	for i := 0; i < 10; i++ {
		fmt.Print(gen.Next(), " ")
	}
	fmt.Println()

}
Output:

JN JO JP JQ JR JS JT JU JV JW

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator can encode integers into base62 strings.

func New

func New(initID uint64) *Generator

NewGenerator creates a new generator using the provided init number.

func (*Generator) Next

func (g *Generator) Next() string

Next returns a next ID in base62.

Jump to

Keyboard shortcuts

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