{"id":42251627,"url":"https://github.com/tee-ck/go-random","last_synced_at":"2026-01-27T05:11:45.771Z","repository":{"id":57632213,"uuid":"411280259","full_name":"tee-ck/go-random","owner":"tee-ck","description":"a simple random data generator for Golang","archived":false,"fork":false,"pushed_at":"2023-03-16T15:44:48.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-06-20T12:52:43.523Z","etag":null,"topics":["crypto","go","golang","golang-library","golang-package","random","random-generation","random-number-generators","randomizer"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tee-ck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-28T12:52:14.000Z","updated_at":"2021-09-30T09:46:15.000Z","dependencies_parsed_at":"2024-06-20T12:05:40.829Z","dependency_job_id":"22c7100a-4363-4cf3-a35b-687bd74500cf","html_url":"https://github.com/tee-ck/go-random","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tee-ck/go-random","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tee-ck%2Fgo-random","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tee-ck%2Fgo-random/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tee-ck%2Fgo-random/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tee-ck%2Fgo-random/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tee-ck","download_url":"https://codeload.github.com/tee-ck/go-random/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tee-ck%2Fgo-random/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28803648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crypto","go","golang","golang-library","golang-package","random","random-generation","random-number-generators","randomizer"],"created_at":"2026-01-27T05:11:45.093Z","updated_at":"2026-01-27T05:11:45.764Z","avatar_url":"https://github.com/tee-ck.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-random\nA simple random data generator based on Golang standard libraries \"math/rand\" and \"crypto/rand\"\n\n# requirements\ngo version \u003e 1.18\n\n# Installation\n\n```shell\ngo get -u github.com/tee-ck/go-random\n```\n\n# Usage\n\nBased on math/rand\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/tee-ck/go-random\"\n\t\"time\"\n)\n\nfunc main() {\n\t// generate a random string with default characters and length given (32 characters)\n\tfmt.Println(random.RandString(32))\n\t// output: 9FgvfIBSlIQUvRqqB5WcGwFbofO8OjKO\n\n\t// generate a random string with characters given and length given (24 characters) by function chain\n\tfmt.Println(random.WithChars(\"0123456789\").RandString(24))\n\t// output: 413864904880075041479896\n\n\t// generate a random string with seed given and length given (24 characters) by function chain\n\tfmt.Println(random.WithSeed(time.Now().UnixNano()).RandString(24))\n\t// output: D3nQ5hwH9HIW03neQERsEgIC\n\n\t// generate a random int between 10 and 100\n\tfmt.Println(random.RandInt(10, 100))\n\t// output: 74\n\n\t// generate a byte slice ([]byte) with length given (12)\n\tfmt.Println(random.Bytes(12))\n\t// output: [1 207 75 27 249 186 141 7 72 44 85 88]\n\n\t// generate a rune slice ([]rune) with default characters and length given (12)\n\tfmt.Println(random.Runes(12))\n\t// output: [89 116 89 98 105 90 69 70 110 65 119 48]\n\n\t// generate a random 64 bit integer\n\tfmt.Println(random.Int63())\n\t// output: 5928505690140062246\n\n\t// generate a random 32 bit integer\n\tfmt.Println(random.Int31())\n\t// output: 588574091\n\n\t// generate a random 32 bit floating point\n\tfmt.Println(random.Float32())\n\t// output: 0.16250405\n\n\t// generate a random 64 bit floating point\n\tfmt.Println(random.Float64())\n\t// output: 0.10604198575158426\n}\n```\n\nBased on crypto/rand\n\n- crypto functions usually require error handling\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/tee-ck/go-random\"\n\t\"log\"\n)\n\nfunc main() {\n\t// first, create a crypto randomizer\n\tc := random.Crypto()\n\n\t// generate a random string with default characters and length given (32 characters)\n\tv, err := c.RandString(32)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(v)\n\t// output: 7kRBEJcGl0tBzYYCojM1j7N9Y3mrlPOv\n\n\t// generate a random string with characters given and length given (24 characters) by function chain\n\tv, err = c.WithChars(\"0123456789abcdef\").RandString(24)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(v)\n\t// output: 890ce6af8a62cdd2b8566b77\n\n\t// generate a random string with characters given and length given (24 characters) by function chain\n\tv, err = c.WithChars(random.CharsRomanLettersUpper).RandString(24)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(v)\n\t// output: MQESAKHTHRABBOAXPJBYVTOO\n\n\t// or you can use crypto randomizer by function chain\n\tv, err = random.Crypto().RandString(24)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(v)\n\t// output: 95d4457abcebb294e9388674\n\n\t/// ...\n\t// same with above math/rand, just need to do the extra error handling\n}\n```\n\n# Benchmarks\n\n```shell\nPS C:\\Programming\\.projects\\.public\\go-random\u003e go version\ngo version go1.19 windows/amd64\nPS C:\\Programming\\.projects\\.public\\go-random\u003e go test -bench . -benchmem\ngoos: windows\ngoarch: amd64\npkg: github.com/tee-ck/go-random\ncpu: 12th Gen Intel(R) Core(TM) i5-12600K\nBenchmarkRandom_Bytes32-16                      39999866                28.81 ns/op           32 B/op          1 allocs/op\nBenchmarkRandom_Int-16                          551555500                2.147 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_Int31-16                        668201673                1.774 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_Int63-16                        664688479                1.783 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_Uint32-16                       662852685                1.768 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_Uint64-16                       507398289                2.332 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_Float32-16                      330874932                3.513 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_FastFloat32-16                  664313151                1.772 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_Float64-16                      481848950                2.508 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_Runes32-16                       8571152               138.1 ns/op           128 B/op          1 allocs/op\nBenchmarkRandom_RandString32-16                  4600060               256.8 ns/op           176 B/op          2 allocs/op\nBenchmarkRandom_RandString64-16                  2546078               469.9 ns/op           336 B/op          2 allocs/op\nBenchmarkRandom_Choice-16                       396812930                2.958 ns/op           0 B/op          0 allocs/op\nBenchmarkRandom_CryptoChoice-16                 10788126               111.3 ns/op            32 B/op          2 allocs/op\nBenchmarkCryptoRandom_Bytes32-16                 8807842               135.2 ns/op            56 B/op          2 allocs/op\nBenchmarkCryptoRandom_Int-16                     7339480               163.3 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastInt-16                10792628               111.2 ns/op            32 B/op          2 allocs/op\nBenchmarkCryptoRandom_Int15-16                   7547150               157.8 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_Int31-16                   7287877               162.3 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastInt31-16              11311236               106.5 ns/op            28 B/op          2 allocs/op\nBenchmarkCryptoRandom_Int63-16                   7450393               162.6 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastInt63-16              10666524               110.7 ns/op            32 B/op          2 allocs/op\nBenchmarkCryptoRandom_Uint16-16                  7669504               157.9 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_Uint32-16                  7414854               161.4 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastUint32-16             11327775               104.8 ns/op            28 B/op          2 allocs/op\nBenchmarkCryptoRandom_Uint64-16                  7500018               160.8 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastUint64-16             11316878               109.7 ns/op            32 B/op          2 allocs/op\nBenchmarkCryptoRandom_Float32-16                 7318242               160.8 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastFloat32-16            11555961               105.5 ns/op            28 B/op          2 allocs/op\nBenchmarkCryptoRandom_Float64-16                 7375858               161.3 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastFloat64-16            10811073               110.8 ns/op            32 B/op          2 allocs/op\nBenchmarkCryptoRandom_Runes32-16                  222214              5305 ns/op            2432 B/op        129 allocs/op\nBenchmarkCryptoRandom_FastRunes32-16              324321              3616 ns/op            1152 B/op         65 allocs/op\nBenchmarkCryptoRandom_RandString32-16             216213              5467 ns/op            2480 B/op        130 allocs/op\nBenchmarkCryptoRandom_FastRandString32-16         319977              3743 ns/op            1200 B/op         66 allocs/op\nBenchmarkCryptoRandom_RandString64-16             110599             11077 ns/op            4944 B/op        258 allocs/op\nBenchmarkCryptoRandom_FastRandString64-16         161073              7473 ns/op            2384 B/op        130 allocs/op\nBenchmarkCryptoRandom_Choice-16                  5638254               212.1 ns/op           112 B/op          6 allocs/op\nBenchmarkCryptoRandom_FastChoice-16              7537574               160.8 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_ChoiceStrings-16           7323315               163.4 ns/op            72 B/op          4 allocs/op\nBenchmarkCryptoRandom_FastChoiceStrings-16      10793443               111.6 ns/op            32 B/op          2 allocs/op\nPASS\nok      github.com/tee-ck/go-random     55.695s\n```\n\n# License\n\nThe project is licensed under MIT license.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftee-ck%2Fgo-random","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftee-ck%2Fgo-random","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftee-ck%2Fgo-random/lists"}