Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "%!s" in the output of a float?

Tags:

go

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)(?)

like image 854
aliona matveeva Avatar asked Sep 20 '25 01:09

aliona matveeva


1 Answers

https://golang.org/pkg/fmt/

%!s is basically used in errors to help you identify a problem.

like image 55
Strainger Avatar answered Sep 22 '25 22:09

Strainger