id

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package id generates unique random strings. It however should not be used for cryptography purposes.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() string

New returns a new random string.

Example
package main

import (
	"fmt"

	"github.com/komuw/ong/id"
)

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

func Random

func Random(n int) string

Random generates a random string of size n.

If n < 1 or significantly large, it is set to reasonable bounds. It uses `crypto/rand` but falls back to `math/rand` on error.

Example
package main

import (
	"fmt"

	"github.com/komuw/ong/id"
)

func main() {
	size := 34
	s := id.Random(size)
	if len(s) != size {
		panic("mismatched sizes")
	}
	fmt.Println(s)
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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