randstr
This is a library for generating various random data to use in the program.
Prerequisites
Installation
go get -u github.com/135yshr/rand
Lean more
How to generate random ID
The ID generator creates a string using alphanumeric characters.
import (
"fmt"
"github.com/135yshr/rand/randstr"
)
func main() {
gen := randstr.NewUserNameGenerator()
fmt.Printf("Generated ID: %s\n", gen.Generate(8))
}
How to generate random Password
import (
"fmt"
"github.com/135yshr/rand/randstr"
)
func main() {
gen := randstr.NewPasswordGenerator()
fmt.Printf("Generated password: %s\n", gen.Generate(12))
}
How to generate random string
When you want to use specified characters, please use the custom generator.
import (
"fmt"
"github.com/135yshr/rand/randstr"
)
func main() {
gen := randstr.NewCustomGenerator("abcdef01234567890-/")
fmt.Printf("Generated random string: %s\n", gen.Generate(10))
}
Contributing
This project is an open-source endeavor that thrives on your active participation. We're always on the lookout for individuals interested in contributing to the project's growth. If you have any ideas or improvements, no matter how small, they are welcome. Feel free to submit a pull request at any time. We're eagerly awaiting your collaboration!
License
This project is released under the MIT license. See the LICENSE file for details.