Table of Contents
There are many great ways to generate "cryptographical-properly" 6-digit codes in Go; however, I didn't find one that really suited my needs. So I created this simplest one. I created a ONE line of code and few functions for creating array and long digit, for example: 127 length. It's so amazing. That be the best for you as soon as you try it -- I think this is it.
Here's why:
- Your time should be focused on creating something amazing. A function GenerateShort for digit up to length of 7 is the faster than other ways, because it use nanosecond of time on your machine.
- You shouldn't be doing google "How to generate 6-digit number" again and again. Just try it and you would love.
- You should implement DRY principles to the rest of your life ๐
Of course, this project don't suite your purposes if you are creating Pentagon security system. In other way it works great. Use following instruction to install and use it.
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
go get github.com/nanorand/nanorand
for other version
go get github.com/nanorand/[email protected]
replace X for number of version. For example: v0.1.1
package main
import (
"fmt"
"github.com/nanorand/nanorand"
)
func main() {
fmt.Println("6 digit code")
code, err := nanorand.Gen(6)
if err != nil {
return
}
fmt.Println(code)
}
output:
798785
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Kirill Bogomolov - @manazoid - [email protected]
Project Link: https://github.com/nanorand/nanorand