I’m getting coordinates (location) as an output of 2 float64 numbers, and it looks like this:
&{%!s(float64=42.539679) %!s(float64=42.601339)}
This is the first time I’m seeing anything like that, so what is “%!s”?
“TypeOf” says “%!s(float64=42.539679)” is float64. So how do I work with this kind of floats? Is there any way to parse it, or somehow to make the %!s(float64=42.539679) look like 42.539679?
UPD: the highlighted line is a *tgbotapi.Location object from Syfaro’s telegram bot api.
The api has this structure:
type Location struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
}
and the Location.Latitude gives me this: “%!s(float64=42.539679)” (float64)(?)
2
Answers
https://golang.org/pkg/fmt/
%!s is basically used in errors to help you identify a problem.
I think this is a matter of using an incorrect format “verb.” You need to use
%f
instead of%s
Runnable: https://play.golang.org/p/Pec_QrxBIl