{"id":21928090,"url":"https://github.com/depp/bytesize","last_synced_at":"2025-07-14T08:33:52.119Z","repository":{"id":57576791,"uuid":"305223894","full_name":"depp/bytesize","owner":"depp","description":"Format data sizes for humans","archived":false,"fork":false,"pushed_at":"2022-07-21T21:19:12.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"trunk","last_synced_at":"2025-03-22T12:18:45.258Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/depp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-19T00:33:06.000Z","updated_at":"2022-07-21T21:19:14.000Z","dependencies_parsed_at":"2022-09-26T19:02:39.281Z","dependency_job_id":null,"html_url":"https://github.com/depp/bytesize","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/depp/bytesize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/depp","download_url":"https://codeload.github.com/depp/bytesize/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265262744,"owners_count":23736462,"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":[],"created_at":"2024-11-28T22:20:41.163Z","updated_at":"2025-07-14T08:33:52.090Z","avatar_url":"https://github.com/depp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ByteSize\n\n**Simple** and **correct.**\n\nByteSize is a library for formatting and parsing numbers as byte sizes for humans. Numbers are formatted with three digits of precision, using SI prefixes, and the unit \"B\" for bytes. For example, 1000 is formatted as \"1.00 KB\". The numbers are rounded using round-to-even, which is the familiar method used by `fmt.Sprintf`, `math.Round`, and other functions in the standard library.\n\nThere are no choices to make. ByteSize is not configurable.\n\n## Formatting\n\nThe precision cannot be changed. Non-decimal prefixes are not produced: no kibibytes, no powers of two. There is only one function to call.\n\n    func Format(size uint64) string\n\nAll corner cases should be handled correctly and you should never see unusual or unexpected output. You should always see exactly three digits, except for inputs under 100.\n\nSome test cases:\n\n```\n0 =\u003e \"0 B\"\n999 =\u003e \"999 B\"\n1000 =\u003e \"1.00 kB\"\n1005 =\u003e \"1.00 kB\"\n1006 =\u003e \"1.01 kB\"\n1014 =\u003e \"1.01 kB\"\n1015 =\u003e \"1.02 kB\"\n9995 =\u003e \"10.0 kB\"\n314000 =\u003e \"314 kB\"\nmath.MaxInt64 =\u003e \"9.22 EB\"\nmath.MaxUint64 =\u003e \"18.4 EB\"\n```\n\n## Parsing\n\nThe parser understands decimal numbers, decimal SI prefixes, and binary SI prefixes. It is not case-sensitive. ASCII space (0x20) may appear between the number and the units. This will recognize all positve prefixes which are powers of 1,000, including prefixes that will overflow (yotta and zetta).\n\n    func Parse(s string) (uint64, error)\n\nSome test cases:\n\n    \"0\" =\u003e 0\n    \"1\" =\u003e 1\n    \"555k\" =\u003e 555000\n    \"15 EiB\" =\u003e 17293822569102704640\n    \"1.5 mb\" =\u003e 1500000\n    \"2gi\" =\u003e 2147483648\n    \"0.001 zb\" =\u003e 1000000000000000000\n\nOn overflow, this will return `^uint64(0)` and a `ParseError` containing `ErrRange`.\n\n## License\n\nThis is licensed under the MIT license. See LICENSE.txt.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fbytesize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdepp%2Fbytesize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fbytesize/lists"}