random

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package random

  • Version: 1.0.0
  • Copyright (c) 2023. Pashifika *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	Numeric             = "0123456789"                                                      // numeric: [0-9]
	AsciiAlphabetsLower = "abcdefghijklmnopqrstuvwxyz"                                      // Ascii lower alphabets: [a-z]
	AsciiAlphabetsUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                                      // Ascii upper alphabets: [A-Z]
	AsciiAlphabets      = AsciiAlphabetsLower + AsciiAlphabetsUpper                         // Ascii alphabets: [a-zA-Z]
	AsciiCharacters     = AsciiAlphabetsLower + AsciiAlphabetsUpper + Numeric               // Ascii characters: [a-zA-Z0-9]
	Hexadecimal         = "0123456789abcdefABCDEF"                                          // hexadecimal number: [0-9a-fA-F]
	Punctuation         = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"                              // punctuation and special characters
	Printables          = Numeric + AsciiAlphabetsLower + AsciiAlphabetsUpper + Punctuation // printable characters
)

Functions

func Choice added in v0.3.0

func Choice[T comparable](datas []T) T

Choice makes a random choice from a slice.

func ChoiceSlice added in v0.3.0

func ChoiceSlice[T comparable](datas []T, n int) []T

ChoiceSlice select n comparable are random choice in a slice.

func Int added in v0.3.0

func Int(max int) int

Int generates a cryptographically-secure random Int. Provided max must be greater than 0.

func Int64 added in v0.3.0

func Int64(max int64) int64

Int64 generates a cryptographically-secure random Int64. Provided max must be greater than 0.

func IntRange added in v0.3.0

func IntRange(min int, max int) int

IntRange returns a random integer between a given range.

func IntRange64 added in v0.3.0

func IntRange64(min int64, max int64) int64

IntRange64 returns a random big integer between a given range.

func Random added in v0.3.0

func Random(n int, charset string) string

Random is responsible for generating random data from a given character set.

func String

func String(n int) string

String generates a cryptographically secure string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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