xrand

package
v0.25.15 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

README

GoKit - xrand

Rand kits for Golang development.

Installation

go get -u github.com/likexian/gokit

Importing

import (
    "github.com/likexian/gokit/xrand"
)

Documentation

Visit the docs on GoDoc

Example

Rand int between 0 and 10000
n := xrand.Int(10000)
fmt.Println("rand int between 0 and 10000 is:", n)
Rand int between 1000 and 10000
n := xrand.IntRange(1000, 10000)
fmt.Println("rand int between 1000 and 10000 is:", n)
Rand bytes with length of 10
b, err := xrand.Bytes(10)
if err != nil {
    fmt.Println("rand bytes:", b)
}

License

Copyright 2012-2024 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Author

func Author() string

Author returns package author

func Base64

func Base64(n int) (ss string, err error)

Base64 returns base64 string of n random bytes

func Bytes

func Bytes(n int) (bs []byte, err error)

Bytes returns n random bytes

func Hex

func Hex(n int) (ss string, err error)

Hex returns hex string of n random bytes

func Int

func Int(max int) int

Int returns random int in [0, max)

func IntRange

func IntRange(min, max int) int

IntRange returns random int in [min, max)

func License

func License() string

License returns package license

func String

func String(n int) string

String returns n random string from 0-9,a-z,A-Z

func StringRange

func StringRange(n int, source string) string

StringRange returns n random string base on source

func Version

func Version() string

Version returns package version

Types

This section is empty.

Jump to

Keyboard shortcuts

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