How does one convert a float64 to an int in Go? I know the strconv
package can be used to convert anything to or from a string, but not between data types where one isn't a string. I know I can use fmt.Sprintf
to convert anything to a string, and then strconv
it to the data type I need, but this extra conversion seems a bit clumsy – is there a better way to do this?
Go – Convert a float64 to an int in Go
go
Best Answer