comm

package
v0.0.0-...-e8b0599 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Max_Bytes = 20 << 20 // 20MB
View Source
const SizeLimit = 20 * 1024 * 1024 // x MB

Variables

View Source
var (
	ColorReset = "\033[0m"

	ColorRed    = "\033[31m"
	ColorGreen  = "\033[32m"
	ColorYellow = "\033[33m"
	ColorBlue   = "\033[34m"
	ColorPurple = "\033[35m"
	ColorCyan   = "\033[36m"
	ColorWhite  = "\033[37m"
)

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string

func GenerateRandomStringURLSafe

func GenerateRandomStringURLSafe(n int) (string, error)

returns a URL-safe, base64 encoded securely generated random string

func GetCmdlineArg

func GetCmdlineArg(long string, short string) string

func GetCmdlineBool

func GetCmdlineBool(long string, short string) bool

func Lotto

func Lotto(cnt int, out int) []int

func Shuffle

func Shuffle(cnt int) []int

func Shuffle0

func Shuffle0(s Interface)

Shuffle shuffles the data using the following algorithm:

To shuffle an array a of n elements (indices 0..n-1):
  for i from n − 1 downto 1 do
    j ← random integer with 0 ≤ j ≤ i
    exchange a[j] and a[i]

Types

type CryptoSrc

type CryptoSrc struct{}

----- https://programming.guide/go/crypto-rand-int.html

func (CryptoSrc) Int63

func (s CryptoSrc) Int63() int64

func (CryptoSrc) Seed

func (s CryptoSrc) Seed(seed int64)

func (CryptoSrc) Uint64

func (s CryptoSrc) Uint64() (v uint64)

type Interface

type Interface interface {
	// Len is the number of elements in the collection.
	Len() int
	// Swap swaps the elements with indexes i and j.
	Swap(i, j int)
}

----- Fisher–Yates_Shuffle https://github.com/carlmjohnson/go-utils Type Interface is similar to a sort.Interface, but there's no Less method

Jump to

Keyboard shortcuts

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