rand

module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT

README

randstr

go Go Report Card GoDoc MIT License

This is a library for generating various random data to use in the program.

Prerequisites

  • Go: 1.18+

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.

Directories

Path Synopsis
examples
id
Package: randstr provides a function to generate random strings.
Package: randstr provides a function to generate random strings.

Jump to

Keyboard shortcuts

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