https://github.com/thehamdiz/gofigure
gofigure is a go package that converts big numbers into humanized abbreviations as in K, M, B etc...
https://github.com/thehamdiz/gofigure
Last synced: 18 days ago
JSON representation
gofigure is a go package that converts big numbers into humanized abbreviations as in K, M, B etc...
- Host: GitHub
- URL: https://github.com/thehamdiz/gofigure
- Owner: theHamdiz
- Created: 2024-05-12T11:52:31.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-05-12T19:24:40.000Z (12 months ago)
- Last Synced: 2025-02-14T08:37:26.840Z (2 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GoFigure
`GoFigure` is a `Go` package that provides an easy way to format large numbers into more readable strings with abbreviations like `K`, `M`, `B`, `T`, `Q`, and `Qi`.
## Installation
Install GoFigure using the following command:
```bash
go get github.com/theHamdiz/gofigure
```### Usage
> Here's how to use `GoFigure` in your `Go` programs:
```go
package mainimport (
"fmt""github.com/theHamdiz/gofigure"
)func main() {
fmt.Println(gofigure.FormatFigure(123)) // Output: "123"
fmt.Println(gofigure.FormatFigure(1234)) // Output: "1.2K"
fmt.Println(gofigure.FormatFigure(1234567)) // Output: "1.2M"
fmt.Println(gofigure.FormatFigure(1234567890)) // Output: "1.2B"
fmt.Println(gofigure.FormatFigure(1234567890123.4)) // Output: "1.2T"
fmt.Println(gofigure.FormatFigure("1234567890123456")) // Output: "1.2Q"
fmt.Println(gofigure.FormatFigure(1234567890123456789)) // Output: "1.2Qi"
}```
## Change Log:
> `v0.1.1`
> - `FormatFigure()` now accepts `interface{}`.
> - Any number (`int`, `uint`, `float`) are accepted.
> - Any `string` representative of a number is also accepted.
> - `FormatFigure()` now returns `(string, error)` instead of just `string`.> `v0.1.3`
> - Fixed a formatting bug.
> - Added some gigantic numbers.