-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Silicon-Ally/grady/edits
Example, Typo, Attribution Tweak
- Loading branch information
Showing
2 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters