Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/susisu/go-random
go-random provides generic random number generator interfaces and functions
https://github.com/susisu/go-random
Last synced: 2 days ago
JSON representation
go-random provides generic random number generator interfaces and functions
- Host: GitHub
- URL: https://github.com/susisu/go-random
- Owner: susisu
- License: mit
- Created: 2023-03-04T06:36:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T12:46:40.000Z (almost 2 years ago)
- Last Synced: 2024-11-06T04:41:32.200Z (about 2 months ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/susisu/go-random
- Size: 48.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-random
[![CI](https://github.com/susisu/go-random/workflows/CI/badge.svg)](https://github.com/susisu/go-random/actions?query=workflow%3ACI)
go-random provides generic random number generator interfaces and functions.
## Usage
Use `go get` to install:
``` shell
go get github.com/susisu/go-random
```go-random provides functions for both uint32 and uint64 generators.
The functions for each type are exported from separate pacakges, so use the appropriate one for your use case.Here is an example using the uint64 version:
``` go
package mainimport (
"fmt"
"math/rand"random "github.com/susisu/go-random/uint64"
)func main() {
// math/rand.Source64 implements the uint64 version of random.Generator
g := rand.NewSource(42).(rand.Source64)
// use go-random to generate random values of variaous numeric types
v := random.Float64(g)
fmt.Printf("%f\n", v)
}
```## License
[MIT License](http://opensource.org/licenses/mit-license.php)
## Author
Susisu ([GitHub](https://github.com/susisu), [Twitter](https://twitter.com/susisu2413))