When you cast a float64 to an int it will just remove the fractional part. By adding 0.5 to the number you will get the behaviour of it rounding the number.
package main
import "fmt"
func main() {
fmt.Printf("roundInt(1.0): %v\n", roundInt(1.0))
fmt.Printf("roundInt(1.4): %v\n", roundInt(1.4))
fmt.Printf("roundInt(1.5): %v\n", roundInt(1.5))
fmt.Printf("roundInt(11.9): %v\n", roundInt(11.9))
}
func roundInt(f float64) int {
return int(f + .5)
}