Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/text/number: support formatting of custom types #28451

Open
ainar-g opened this Issue Oct 28, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@ainar-g
Copy link
Contributor

ainar-g commented Oct 28, 2018

This is based on a StackOverflow question.

Package golang.org/x/text/number allows locale-specific formatting of numbers à-la fmt. Unfortunately, unlike fmt, this package doesn't have an interface to let types other than the built-in numeric types tell the package how to format them. Or rather, the interface is there, but it's in an internal package, so the users can't really implement it.

This wouldn't be bad if math/big types or types whose String() method produces numbers were supported, but as of now that is still a TODO.

@gopherbot gopherbot added this to the Unreleased milestone Oct 28, 2018

@ainar-g ainar-g changed the title x/text/number: support custom formatting x/text/number: support formatting of custom types Oct 28, 2018

@ainar-g

This comment has been minimized.

Copy link
Contributor Author

ainar-g commented Dec 1, 2018

This may or may not be a dup of #15274, although that issue only concerns currency amounts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.