Rounding To An Interval In Go

🎓 A collection of things I've learned


Rounding To An Interval In Go

// roundTo defines the value to round all prices to the nearest of
// For intance, roundTo: 50
//		487 -> 500
//		472 -> 450
//
func (price *Price) roundTo(val, roundVal float64) float64 {
	return math.Round(val/roundVal) * roundVal
}