base62

package module
v0.0.0-...-319fac4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: Apache-2.0, MIT Imports: 3 Imported by: 1

README

Base62

Encode uint64 into a base62 string value, or decode a base62 string into an int64 value.

Usage

package main

import (
    "fmt"
    "github.com/divinerapier/base62"
)

func ExampleEncode() {
 fmt.Println(Encode(18446744073709551615))
 // Output: lYGhA16ahyf
}

func ExampleDecode() {
 fmt.Println(Decode("lYGhA16ahyf"))
 // Output: 18446744073709551615 <nil>
}

Documentation

Index

Examples

Constants

View Source
const Charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

Variables

View Source
var (
	ErrOverflow         = errors.New("value is overflow")
	ErrInvalidCharacter = errors.New("invalid character")
)

Functions

func BatchDecode

func BatchDecode(batch []string) ([]uint64, error)

func BatchEncode

func BatchEncode(batch []uint64) []string

func Decode

func Decode(value string) (uint64, error)
Example
fmt.Println(Decode("lYGhA16ahyf"))
Output:
18446744073709551615 <nil>

func Encode

func Encode(value uint64) string
Example
fmt.Println(Encode(18446744073709551615))
Output:
lYGhA16ahyf

func IsOverflow

func IsOverflow(err error) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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