{"id":25842750,"url":"https://github.com/nir3x/varsizedint","last_synced_at":"2026-06-09T06:03:15.165Z","repository":{"id":217954003,"uuid":"745024325","full_name":"NIR3X/varsizedint","owner":"NIR3X","description":"VarsizedInt - Variable-Sized Integer Encoding in Go","archived":false,"fork":false,"pushed_at":"2024-02-16T04:04:36.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T20:08:19.076Z","etag":null,"topics":["efficiency","encoding","go","golang","integer","storage","variable-sized"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NIR3X.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":"2024-01-18T13:46:59.000Z","updated_at":"2024-01-18T13:48:03.000Z","dependencies_parsed_at":"2024-06-21T19:19:51.946Z","dependency_job_id":"448eb5db-019e-4261-995e-53b941fea4b1","html_url":"https://github.com/NIR3X/varsizedint","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"441eede8d8cda43904a519b4c147bf4795fd6d8d"},"previous_names":["nir3x/varsizedint"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fvarsizedint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fvarsizedint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fvarsizedint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fvarsizedint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NIR3X","download_url":"https://codeload.github.com/NIR3X/varsizedint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241329448,"owners_count":19944982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["efficiency","encoding","go","golang","integer","storage","variable-sized"],"created_at":"2025-03-01T06:31:33.865Z","updated_at":"2026-06-09T06:03:15.127Z","avatar_url":"https://github.com/NIR3X.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VarsizedInt - Variable-Sized Integer Encoding in Go\n\nVarsizedInt is a Go package that offers functionality for encoding and decoding variable-sized integers. This encoding scheme is specifically designed to efficiently represent integers of different sizes, optimizing storage space for smaller values while accommodating larger integers.\n\n## Installation\n\nTo use this package, you can include it in your Go project using the following go get command:\n\n```bash\ngo get -u github.com/NIR3X/varsizedint\n\n```\n\n## Usage\n\nHere is an example of how to use VarsizedInt in your Go code:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/NIR3X/varsizedint\"\n)\n\nfunc main() {\n\t// Example usage of VarsizedInt encoding and decoding\n\n\t// Encode and Decode a variable-sized integer\n\toriginalValue := uint64(123456789)\n\tencodedData := make([]uint8, varsizedint.MaxSize)\n\tencodedSize := varsizedint.Encode(encodedData, originalValue)\n\n\t// Display encoded data\n\tfmt.Print(\"Encoded Data: \")\n\tfor i := 0; i \u003c encodedSize; i++ {\n\t\tfmt.Printf(\"%#02x \", encodedData[i])\n\t}\n\tfmt.Println()\n\n\t// Decode the data\n\tdecodedValue := varsizedint.Decode(encodedData)\n\tfmt.Printf(\"Decoded Value: %d 0x%016x\\n\", decodedValue, decodedValue)\n}\n```\n\nIn this example, a variable-sized integer (`originalValue`) is encoded using VarsizedInt, and the resulting encoded data is displayed in hexadecimal format. Subsequently, the encoded data is decoded back to its original value. The example showcases the simplicity and effectiveness of VarsizedInt in encoding and decoding variable-sized integers. The `varsizedint.MaxSize` constant represents the maximum size in bytes that an encoded integer can occupy.\n\n## Variable-Sized Integer Ranges and Efficiency\n\nVarsizedInt is designed to efficiently encode variable-sized integers, optimizing storage based on the value range. The following table illustrates the relationship between the value range, encoded size, and the number of bits lost to size encoding:\n| Value Range              | Encoded Size | Bits Lost to Size Encoding   |\n| ------------------------ | ------------ | ---------------------------- |\n| 0 - 127                  | 1 byte       | 1 bit                        |\n| 0 - 16383                | 2 bytes      | 2 bits                       |\n| 0 - 2097151              | 3 bytes      | 3 bits                       |\n| 0 - 268435455            | 4 bytes      | 4 bits                       |\n| 0 - 34359738367          | 5 bytes      | 5 bits                       |\n| 0 - 4398046511103        | 6 bytes      | 6 bits                       |\n| 0 - 562949953421311      | 7 bytes      | 7 bits                       |\n| 0 - 72057594037927935    | 8 bytes      | 8 bits                       |\n| 0 - 18446744073709551615 | 9 bytes      | 8 bits (limited by encoding) |\n\nFeel free to integrate VarsizedInt into your Go projects to efficiently store variable-sized integers with reduced storage overhead.\n\n## License\n\n[![GNU AGPLv3 Image](https://www.gnu.org/graphics/agplv3-155x51.png)](https://www.gnu.org/licenses/agpl-3.0.html)\n\nThis program is Free Software: You can use, study share and improve it at your\nwill. Specifically you can redistribute and/or modify it under the terms of the\n[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html) as\npublished by the Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnir3x%2Fvarsizedint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnir3x%2Fvarsizedint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnir3x%2Fvarsizedint/lists"}