Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lyrictian/rand
A random library for Go.
https://github.com/lyrictian/rand
go-rand shorturl
Last synced: 9 days ago
JSON representation
A random library for Go.
- Host: GitHub
- URL: https://github.com/lyrictian/rand
- Owner: LyricTian
- License: mit
- Created: 2018-11-01T11:17:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-05T06:27:48.000Z (about 6 years ago)
- Last Synced: 2024-11-06T07:30:05.380Z (about 2 months ago)
- Topics: go-rand, shorturl
- Language: Go
- Homepage: https://godoc.org/github.com/LyricTian/rand
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rand
> A random library for Go.
[![Build][build-status-image]][build-status-url] [![Codecov][codecov-image]][codecov-url] [![ReportCard][reportcard-image]][reportcard-url] [![GoDoc][godoc-image]][godoc-url] [![License][license-image]][license-url]
## Usage
```bash
$ go get -u -v github.com/LyricTian/rand
```### Import package
```go
import "github.com/LyricTian/rand"
```### Generate a random string
```go
rand.MustRandom(6, rand.Ldigit)
// 939430
```### Generate a short string
```go
rand.MustShortStr([]byte("https://www.google.com"), 6, rand.Ldigit)
// [XZ1599 Xy8I3U KAHc2K NftD8p]
```#### Random flag:
- Ldigit
- LlowerCase
- LupperCase
- LlowerAndUpperCase
- LdigitAndLowerCase
- LdigitAndUpperCase
- LdigitAndLetter### Generate a random UUID
```go
rand.MustUUID()
// a306e54f-672f-4011-889d-d09e98cbea89
```## MIT License
Copyright (c) 2018 Lyric
[build-status-url]: https://travis-ci.org/LyricTian/rand
[build-status-image]: https://travis-ci.org/LyricTian/rand.svg?branch=master
[codecov-url]: https://codecov.io/gh/LyricTian/rand
[codecov-image]: https://codecov.io/gh/LyricTian/rand/branch/master/graph/badge.svg
[reportcard-url]: https://goreportcard.com/report/github.com/LyricTian/rand
[reportcard-image]: https://goreportcard.com/badge/github.com/LyricTian/rand
[godoc-url]: https://godoc.org/github.com/LyricTian/rand
[godoc-image]: https://godoc.org/github.com/LyricTian/rand?status.svg
[license-url]: http://opensource.org/licenses/MIT
[license-image]: https://img.shields.io/npm/l/express.svg