https://github.com/dariubs/percent
Simple library for calculate percentages in Go.
https://github.com/dariubs/percent
calculate-percentages godoc percent percentage
Last synced: 7 months ago
JSON representation
Simple library for calculate percentages in Go.
- Host: GitHub
- URL: https://github.com/dariubs/percent
- Owner: dariubs
- License: mit
- Created: 2016-10-12T10:37:15.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-13T09:11:06.000Z (over 1 year ago)
- Last Synced: 2024-06-18T16:58:26.064Z (over 1 year ago)
- Topics: calculate-percentages, godoc, percent, percentage
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 46
- Watchers: 3
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
golang percent package
====================== [](https://pkg.go.dev/github.com/dariubs/percent) [](https://goreportcard.com/report/github.com/dariubs/percent)
Calculate percentage in Golang.
## Install
```shell
go get github.com/dariubs/percent
```## Usage
```go
// Percent - calculate what %[number1] of [number2] is.
percent.Percent(25, 200) // return 50
percent.PercentFloat(25.0, 200.0) // return 50.0// PercentOf - calculate what percent [number1] is of [number2].
percent.PercentOf(300, 2400) // return 12.5
percent.PercentOfFloat(300.0, 2400.0) // return 12.5// Change - calculate the percent increase/decrease from two numbers.
percent.Change(20, 60) // return 200.0
percent.ChangeFloat(20.0, 60.0) // return 200.0
```## Documentation
[GoDoc](https://pkg.go.dev/github.com/dariubs/percent)
## License
MIT
## Author
Dariush Abbasi ([@dariubs](https://github.com/dariubs) )