{"id":13413941,"url":"https://github.com/dustin/go-humanize","last_synced_at":"2025-05-13T10:52:53.278Z","repository":{"id":2218556,"uuid":"3168225","full_name":"dustin/go-humanize","owner":"dustin","description":"Go Humans! (formatters for units to human friendly sizes)","archived":false,"fork":false,"pushed_at":"2025-03-24T21:45:08.000Z","size":93,"stargazers_count":4520,"open_issues_count":45,"forks_count":239,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-05-05T17:33:35.121Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/dustin/go-humanize","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dustin.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-01-13T03:48:55.000Z","updated_at":"2025-05-05T06:05:13.000Z","dependencies_parsed_at":"2025-04-08T17:01:01.814Z","dependency_job_id":"122f96ae-b424-449b-a276-ff5b3acdae22","html_url":"https://github.com/dustin/go-humanize","commit_stats":{"total_commits":125,"total_committers":28,"mean_commits":4.464285714285714,"dds":"0.28800000000000003","last_synced_commit":"bd1b3e1a20a1e20fca7346f89ecfaef77afe0474"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustin%2Fgo-humanize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustin%2Fgo-humanize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustin%2Fgo-humanize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustin%2Fgo-humanize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dustin","download_url":"https://codeload.github.com/dustin/go-humanize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252542666,"owners_count":21765004,"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-07-30T20:01:53.265Z","updated_at":"2025-05-05T17:33:46.780Z","avatar_url":"https://github.com/dustin.png","language":"Go","funding_links":[],"categories":["Go","Text Processing","Uncategorized","Template Engines","文本处理","Specific Formats","文本处理`解析和操作文本的代码库`","Bot Building","\u003cspan id=\"文字处理-text-processing\"\u003e文字处理 Text Processing\u003c/span\u003e"],"sub_categories":["Formatters","Advanced Console UIs","Uncategorized","格式器","格式化工具","HTTP Clients","查询语","交流","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"# Humane Units [![Build Status](https://travis-ci.org/dustin/go-humanize.svg?branch=master)](https://travis-ci.org/dustin/go-humanize) [![GoDoc](https://godoc.org/github.com/dustin/go-humanize?status.svg)](https://godoc.org/github.com/dustin/go-humanize)\n\nJust a few functions for helping humanize times and sizes.\n\n`go get` it as `github.com/dustin/go-humanize`, import it as\n`\"github.com/dustin/go-humanize\"`, use it as `humanize`.\n\nSee [godoc](https://pkg.go.dev/github.com/dustin/go-humanize) for\ncomplete documentation.\n\n## Sizes\n\nThis lets you take numbers like `82854982` and convert them to useful\nstrings like, `83 MB` or `79 MiB` (whichever you prefer).\n\nExample:\n\n```go\nfmt.Printf(\"That file is %s.\", humanize.Bytes(82854982)) // That file is 83 MB.\n```\n\n## Times\n\nThis lets you take a `time.Time` and spit it out in relative terms.\nFor example, `12 seconds ago` or `3 days from now`.\n\nExample:\n\n```go\nfmt.Printf(\"This was touched %s.\", humanize.Time(someTimeInstance)) // This was touched 7 hours ago.\n```\n\nThanks to Kyle Lemons for the time implementation from an IRC\nconversation one day. It's pretty neat.\n\n## Ordinals\n\nFrom a [mailing list discussion][odisc] where a user wanted to be able\nto label ordinals.\n\n    0 -\u003e 0th\n    1 -\u003e 1st\n    2 -\u003e 2nd\n    3 -\u003e 3rd\n    4 -\u003e 4th\n    [...]\n\nExample:\n\n```go\nfmt.Printf(\"You're my %s best friend.\", humanize.Ordinal(193)) // You are my 193rd best friend.\n```\n\n## Commas\n\nWant to shove commas into numbers? Be my guest.\n\n    0 -\u003e 0\n    100 -\u003e 100\n    1000 -\u003e 1,000\n    1000000000 -\u003e 1,000,000,000\n    -100000 -\u003e -100,000\n\nExample:\n\n```go\nfmt.Printf(\"You owe $%s.\\n\", humanize.Comma(6582491)) // You owe $6,582,491.\n```\n\n## Ftoa\n\nNicer float64 formatter that removes trailing zeros.\n\n```go\nfmt.Printf(\"%f\", 2.24)                // 2.240000\nfmt.Printf(\"%s\", humanize.Ftoa(2.24)) // 2.24\nfmt.Printf(\"%f\", 2.0)                 // 2.000000\nfmt.Printf(\"%s\", humanize.Ftoa(2.0))  // 2\n```\n\n## SI notation\n\nFormat numbers with [SI notation][sinotation].\n\nExample:\n\n```go\nhumanize.SI(0.00000000223, \"M\") // 2.23 nM\n```\n\n## English-specific functions\n\nThe following functions are in the `humanize/english` subpackage.\n\n### Plurals\n\nSimple English pluralization\n\n```go\nenglish.PluralWord(1, \"object\", \"\") // object\nenglish.PluralWord(42, \"object\", \"\") // objects\nenglish.PluralWord(2, \"bus\", \"\") // buses\nenglish.PluralWord(99, \"locus\", \"loci\") // loci\n\nenglish.Plural(1, \"object\", \"\") // 1 object\nenglish.Plural(42, \"object\", \"\") // 42 objects\nenglish.Plural(2, \"bus\", \"\") // 2 buses\nenglish.Plural(99, \"locus\", \"loci\") // 99 loci\n```\n\n### Word series\n\nFormat comma-separated words lists with conjuctions:\n\n```go\nenglish.WordSeries([]string{\"foo\"}, \"and\") // foo\nenglish.WordSeries([]string{\"foo\", \"bar\"}, \"and\") // foo and bar\nenglish.WordSeries([]string{\"foo\", \"bar\", \"baz\"}, \"and\") // foo, bar and baz\n\nenglish.OxfordWordSeries([]string{\"foo\", \"bar\", \"baz\"}, \"and\") // foo, bar, and baz\n```\n\n[odisc]: https://groups.google.com/d/topic/golang-nuts/l8NhI74jl-4/discussion\n[sinotation]: http://en.wikipedia.org/wiki/Metric_prefix\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustin%2Fgo-humanize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdustin%2Fgo-humanize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustin%2Fgo-humanize/lists"}