wttr.in/internal/geo/location/location.go

27 lines
490 B
Go
Raw Normal View History

package location
2022-12-11 08:36:11 +00:00
import (
"encoding/json"
"log"
)
type Location struct {
2022-12-11 08:36:11 +00:00
Name string `db:"name,key"`
Lat string `db:"lat"`
Lon string `db:"lon"`
Timezone string `db:"timezone"`
2022-12-11 13:28:34 +00:00
//nolint:tagliatelle
Fullname string `db:"displayName" json:"display_name"`
2022-12-11 08:36:11 +00:00
}
2022-12-11 13:28:34 +00:00
// String returns string representation of location.
2022-12-11 08:36:11 +00:00
func (l *Location) String() string {
bytes, err := json.Marshal(l)
if err != nil {
// should never happen
log.Fatalln(err)
}
return string(bytes)
}