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
Int generates a cryptographically-secure random Int. Provided max must be greater than 0.
func Int64 ¶ added in v0.3.0
Int64 generates a cryptographically-secure random Int64. Provided max must be greater than 0.
func IntRange64 ¶ added in v0.3.0
IntRange64 returns a random big integer between a given range.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.