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 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址