package main import ( \"fmt\" \"strconv\" ) func main() { k := 10/3.0 i := fmt.Sprintf(\"%.2f\", k) f,_ := strconv.ParseFloat(i, 2) fmt.Pri
This is a little workaround how can you round float using type conversion to int back and forth:
package main import ( "fmt" ) func main() { k := 10 / 3.0 k = float64(int(k*100)) / 100 fmt.Println(k) // output 3.33 }
https://play.golang.org/p/yg2QYcZ-2u