{"id":22979887,"url":"https://github.com/iamlongalong/bytesizer","last_synced_at":"2025-04-02T09:21:37.583Z","repository":{"id":227197384,"uuid":"770690653","full_name":"iamlongalong/bytesizer","owner":"iamlongalong","description":"🚀 Meet bytesizer: The pocket-sized superhero for byte manipulation in Go! Whether you're calculating, converting, or formatting - bytesizer handles all your byte-bending adventures with ease. Grab it now and give your data sizes a snazzy new spandex suit! 🎉✨","archived":false,"fork":false,"pushed_at":"2024-03-12T05:36:54.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-08T00:28:23.788Z","etag":null,"topics":["bytes","bytesize","golang-package"],"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/iamlongalong.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-03-12T01:36:41.000Z","updated_at":"2024-03-12T05:32:21.000Z","dependencies_parsed_at":"2024-03-12T05:31:49.897Z","dependency_job_id":"2683ae0d-d2a9-4490-89b4-7371f381db38","html_url":"https://github.com/iamlongalong/bytesizer","commit_stats":null,"previous_names":["iamlongalong/bytesizer"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamlongalong%2Fbytesizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamlongalong%2Fbytesizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamlongalong%2Fbytesizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamlongalong%2Fbytesizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamlongalong","download_url":"https://codeload.github.com/iamlongalong/bytesizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246785474,"owners_count":20833503,"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":["bytes","bytesize","golang-package"],"created_at":"2024-12-15T01:34:55.480Z","updated_at":"2025-04-02T09:21:37.563Z","avatar_url":"https://github.com/iamlongalong.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bytesizer\n\n`bytesizer` is a Go package that provides a simple and intuitive way to work with byte counts. It allows you to easily convert between different units of byte sizes, such as bytes, kilobytes, megabytes, gigabytes, terabytes, and petabytes. Similar to how `time.Duration` works in Go, `bytesizer` helps in representing byte sizes with appropriate types and methods.\n\n## Features\n\n- Conversion between byte units and bytes\n- Formatting of byte sizes into human-readable strings\n- Parsing of strings into byte sizes with support for different units\n- Fetching byte sizes as integer or floating-point numbers for precision work\n\n## Installation\n\nTo install `bytesizer`, you can use the following Go command:\n\n```bash\ngo get github.com/iamlongalong/bytesizer\n```\n\nReplace `iamlongalong` with your actual GitHub username where the package is hosted.\n\n## Usage\n\nBelow you'll find the methods provided by the `bytesizer` package and some examples of how to use them.\n\n### Constants\n\n`bytesizer` defines the following byte size units:\n\n```go\nconst (\n\tByte ByteSize = 1 \u003c\u003c (10 * iota)\n\tKB\n\tMB\n\tGB\n\tTB\n\tPB\n)\n```\n\n### Methods\n\n#### Calc\nCalculate the length of a byte slice and return it as a `ByteSize`:\n\n```go\nsize := bytesizer.Calc([]byte(\"Hello World!\"))\n```\n\n#### Format\nFormat a `ByteSize` value to a string according to a specified unit:\n\n```go\nformattedSize := size.Format(bytesizer.KB) // returns string like \"1KB\"\n```\n\n#### String\nConvert a `ByteSize` to a string with an automatic unit:\n\n```go\nsizeString := size.String() // returns string like \"11B\"\n```\n\n#### Byte, KB, MB, GB, TB, PB\nGet the byte size as different units (returns `float64`):\n\n```go\nbytes := size.Byte()\nkilobytes := size.KB()\n// ... and so on for MB, GB, TB, PB\n```\n\n#### ByteInt, KBInt, MBInt, GBInt, TBInt, PBInt\nGet the byte size as different units (returns `int`):\n\n```go\nbytesInt := size.ByteInt()\nkilobytesInt := size.KBInt()\n// ... and so on for MBInt, GBInt, TBInt, PBInt\n```\n\n#### Parse\nParse a string representation of a byte size into a `ByteSize` object:\n\n```go\nsize, err := bytesizer.Parse(\"10KB\")\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Println(size) // Output: 10240 (Bytes equivalent of 10KB)\n```\n\n## Contributing\n\nContributions to `bytesizer` are welcome! Feel free to report issues or submit pull requests on our GitHub repository.\n\n## License\n\nThis package is licensed under the MIT License - see the LICENSE.md file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamlongalong%2Fbytesizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamlongalong%2Fbytesizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamlongalong%2Fbytesizer/lists"}