Skip to content

dariubs/percent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang percent package

test workflow GoDoc Go Report Card

Calculate percentage in Golang.

Install

go get github.com/dariubs/percent

Usage

// 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

License

MIT

Author

Dariush Abbasi (@dariubs )