Randomstring
A Go package for generating random strings
Install / Use
/learn @necmettindev/RandomstringREADME
Random String Generator
This library assists in generating random strings based on specific characteristics. You can create random strings consisting of alphanumeric characters, letters only, digits only, special characters, or even a custom character set.
Features
- Generate strings with alphanumeric, letters only, digits only, or special characters.
- Ability to disable uppercase, lowercase, or numeric characters.
- Option to use a custom character set.
Installation
go get -u github.com/necmettindev/randomstring
Usage
Below are different scenarios demonstrating how to use the randomstring package:
Basic Usage
Generate a string of length 10 using the default alphanumeric characters:
package main
import (
"fmt"
"github.com/necmettindev/randomstring"
)
func main() {
opts := randomstring.GenerationOptions{
Length: 10,
}
result, _ := randomstring.GenerateString(opts)
fmt.Println(result)
}
Disabling Features
For instance, to generate a string containing letters only:
opts := randomstring.GenerationOptions{
Length: 10,
DisableNumeric: true,
}
result, _ := randomstring.GenerateString(opts)
fmt.Println(result)
Using Special Characters
Generate a string with enabled special characters:
opts := randomstring.GenerationOptions{
Length: 15,
EnableSpecialCharacter: true,
}
result, _ := randomstring.GenerateString(opts)
fmt.Println(result)
Using a Custom Character Set
Generate a string with your own custom character set:
opts := randomstring.GenerationOptions{
Length: 12,
CustomCharset: "abcXYZ789",
}
result, _ := randomstring.GenerateString(opts)
fmt.Println(result) // Produces a string consisting only of 'a', 'b', 'c', 'X', 'Y', 'Z', '7', '8', '9'.
Contributing
If you wish to contribute to this project, please first open an issue or pick up an existing one. Then make your contribution and submit a pull request.
License
This project is licensed under the MIT License.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
347.0kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
