Skip to content

Commit

Permalink
Merge pull request #1 from Silicon-Ally/grady/edits
Browse files Browse the repository at this point in the history
Example, Typo, Attribution Tweak
  • Loading branch information
gbdubs authored Jul 11, 2022
2 parents a16fd6b + c9ccb1f commit 65620dd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
_This package brought to you by [Adventure
Scientists](https://adventurescientists.org). Read more about [our open source
policy here](https://siliconally.org/policies/open-source/)._
_This package was developed by [Silicon Ally](https://siliconally.org) while
working on a project for [Adventure Scientists](https://adventurescientists.org).
Many thanks to Adventure Scientists for supporting [our open source
mission](https://siliconally.org/policies/open-source/)!_

# idgen

[![GoDoc](https://pkg.go.dev/badge/github.com/Silicon-Ally/idgen?status.svg)](https://pkg.go.dev/github.com/Silicon-Ally/idgen?tab=doc)

`idegen` is a simple, zero-dependency Go library for generating random
`idgen` is a simple, zero-dependency Go library for generating random
identifiers. It is useful in places where one might want a UUID-like
identifier, but shorter or with more entropy.
identifier, but want to customize length or allowed characters.

## Usage

```golang

import "github.com/Silicon-Ally/idgen"

...
// For security-sensitive applications, use a cryptographically secure rand
// source, like https://github.com/Silicon-Ally/cryptorand for example.
r := rand.New(rand.NewSource(12345))

// Initialize generator with your ID requirements...
generator, err := idgen.New(r, idgen.WithDefaultLength(12), idgen.WithCharSet("abcdef0123456789"))
if err != nil {
return nil, fmt.Error("initializing id generator: %w", err)
}

// Generate IDs!
idA := g.NewID()
idB := g.NewID()
...
```
2 changes: 1 addition & 1 deletion idgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Generator struct {
type Option func(*options)

// WithCharSet specifies the set of characters to use when generating random
// identifiers. If not provided, identifiers default to alphanumerics.
// identifiers. If not provided, identifiers default to case-sensitive alphanumerics.
func WithCharSet(charSet []rune) Option {
return func(opts *options) {
opts.charSet = charSet
Expand Down

0 comments on commit 65620dd

Please sign in to comment.