{"id":13412834,"url":"https://github.com/bojanz/currency","last_synced_at":"2026-01-23T03:12:54.482Z","repository":{"id":40409146,"uuid":"256256886","full_name":"bojanz/currency","owner":"bojanz","description":"Currency handling for Go.","archived":false,"fork":false,"pushed_at":"2026-01-13T09:10:03.000Z","size":194,"stargazers_count":621,"open_issues_count":3,"forks_count":51,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-14T17:48:41.455Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/bojanz/currency","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/bojanz.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-16T15:34:39.000Z","updated_at":"2026-01-12T14:16:11.000Z","dependencies_parsed_at":"2024-01-08T15:02:43.371Z","dependency_job_id":"9207be1d-1add-41f5-964c-d5e6b58a1a94","html_url":"https://github.com/bojanz/currency","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/bojanz/currency","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bojanz%2Fcurrency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bojanz%2Fcurrency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bojanz%2Fcurrency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bojanz%2Fcurrency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bojanz","download_url":"https://codeload.github.com/bojanz/currency/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bojanz%2Fcurrency/sbom","scorecard":{"id":247091,"data":{"date":"2025-08-11","repo":{"name":"github.com/bojanz/currency","commit":"91c5014f7eb5eafa0c1f966c79e6dd66ed131b50"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:66: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/bojanz/currency/build.yml/main?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/build.yml:14","Warn: goCommand not pinned by hash: .github/workflows/build.yml:15","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   2 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T07:47:54.221Z","repository_id":40409146,"created_at":"2025-08-17T07:47:54.221Z","updated_at":"2025-08-17T07:47:54.221Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28679141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T01:00:35.747Z","status":"online","status_checked_at":"2026-01-23T02:00:08.296Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-07-30T20:01:29.828Z","updated_at":"2026-01-23T03:12:54.477Z","avatar_url":"https://github.com/bojanz.png","language":"Go","funding_links":[],"categories":["Financial","金融","Go","Golang","金融领域相关库`处理货币与金融领域的库`","Relational Databases","金融领域相关库"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","SQL 查询语句构建库","Advanced Console UIs"],"readme":"# currency [![Build](https://github.com/bojanz/currency/actions/workflows/build.yml/badge.svg)](https://github.com/bojanz/currency/actions/workflows/build.yml) [![Coverage Status](https://coveralls.io/repos/github/bojanz/currency/badge.svg?branch=master)](https://coveralls.io/github/bojanz/currency?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/bojanz/currency)](https://goreportcard.com/report/github.com/bojanz/currency) [![PkgGoDev](https://pkg.go.dev/badge/github.com/bojanz/currency)](https://pkg.go.dev/github.com/bojanz/currency)\n\nHandles currency amounts, provides currency information and formatting.\n\nPowered by CLDR v48, in just ~40kb of data.\n\nBackstory: https://bojanz.github.io/price-currency-handling-go/\n\n## Features\n\n1. All currency codes, their numeric codes and fraction digits.\n2. Currency symbols and formats for all locales.\n3. Country mapping (country code =\u003e currency code).\n4. Amount struct, with value semantics (Fowler's Money pattern)\n5. Formatter, for formatting amounts and parsing formatted amounts.\n6. Ability to register custom currencies, or override existing ones.\n\n```go\n    amount, _ := currency.NewAmount(\"275.98\", \"EUR\")\n    total, _ := amount.Mul(\"4\")\n\n    locale := currency.NewLocale(\"fr\")\n    formatter := currency.NewFormatter(locale)\n    fmt.Println(formatter.Format(total)) // 1 103,92 €\n\n    // Convert the amount to Iranian rial and show it in Farsi.\n    total, _ = total.Convert(\"IRR\", \"45.538\")\n    total = total.Round()\n    locale = currency.NewLocale(\"fa\")\n    formatter = currency.NewFormatter(locale)\n    fmt.Println(formatter.Format(total)) // ‎ریال ۵۰٬۲۷۰\n```\n\n## Design goals\n\n### Real decimal implementation under the hood.\n\nCurrency amounts can't be floats. Storing integer minor units (2.99 =\u003e 299)\nbecomes problematic once there are multiple currencies (difficult to sort in the\nDB), or there is a need for sub-minor-unit precision (due to merchant or tax\nrequirements, etc). A real arbitrary-precision decimal type is required. Since\nGo doesn't have one natively, a userspace implementation is used, provided by\nthe [cockroachdb/apd](https://github.com/cockroachdb/apd) package. The Amount struct provides an easy to use\nabstraction on top of it, allowing the underlying implementation to be replaced\nin the future without a backwards compatibility break.\n\n### Smart filtering of CLDR data.\n\nThe \"modern\" subset of CLDR locales is used, reducing the list from ~560 to ~370 locales.\n\nOnce gathered, locales are filtered to remove all data not used by this package,\nand then deduplicated by parent (e.g. don't keep `fr-CH` if `fr` has the\nsame data).\n\nCurrency symbols are grouped together to avoid repetition. For example:\n\n    \"ARS\": {\n        {\"ARS\", []string{\"en\", \"fr-CA\"}},\n        {\"$\", []string{\"es-AR\"}},\n        {\"$AR\", []string{\"fr\"}},\n    }\n\nCurrency names are not included because they are rarely shown, but need\nsignificant space. Instead, they can be fetched on the frontend via [Intl.DisplayNames](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames).\n\n### Easy to compare.\n\nAmount structs can be compared via [google/go-cmp](https://github.com/google/go-cmp) thanks to the built-in Equal() method.\n\n### Usable with a PostgreSQL composite type.\n\nThanks to the driver.Valuer and sql.Scanner interfaces, applications using the [pgx](https://github.com/jackc/pgx) driver can store amounts in a composite type.\n\nExample schema:\n```\nCREATE TYPE price AS (\n   number NUMERIC,\n   currency_code TEXT\n);\n\nCREATE TABLE products (\n   id CHAR(26) PRIMARY KEY,\n   name TEXT NOT NULL,\n   price price NOT NULL,\n   created_at TIMESTAMPTZ NOT NULL,\n   updated_at TIMESTAMPTZ\n);\n```\nNote that the number and currency_code columns can have any name, only their ordering matters.\n\nExample struct:\n```go\ntype Product struct {\n\tID          string\n\tName        string\n\tPrice       currency.Amount\n\tCreatedAt   time.Time\n\tUpdatedAt   time.Time\n}\n```\n\nExample scan:\n```go\np := Product{}\nrow := tx.QueryRow(ctx, `SELECT id, name, price, created_at, updated_at FROM products WHERE id = $1`, id)\nerr := row.Scan(\u0026p.ID, \u0026p.Name, \u0026p.Price, \u0026p.CreatedAt, \u0026p.UpdatedAt)\n```\n\nSee our [database integration notes](https://github.com/bojanz/currency/wiki/Database-integration-notes) for other examples (MySQL/MariaDB, SQLite).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbojanz%2Fcurrency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbojanz%2Fcurrency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbojanz%2Fcurrency/lists"}