Skip to content

Implement fmt.Formatter #326

@deitrix

Description

@deitrix

It would be nice if Decimal types implemented the fmt.Formatter interface to allow the use of standard fmt verbs/flags when formatting decimals to strings.

For example:

fmt.Printf("%.2f", decimal.RequireFromString("3.14"))

Would be equivalent to:

fmt.Printf("%s", decimal.RequireFromString("3.14").StringFixed(2))

There are a number of other verbs/flags that could be implemented which can be seen here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions