mirror of
https://github.com/chubin/wttr.in
synced 2025-01-12 12:08:47 +00:00
25 lines
524 B
Go
25 lines
524 B
Go
package location
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
)
|
|
|
|
type Location struct {
|
|
Name string `db:"name,key" json:"name"`
|
|
Lat string `db:"lat" json:"latitude"`
|
|
Lon string `db:"lon" json:"longitude"`
|
|
Timezone string `db:"timezone" json:"timezone"`
|
|
Fullname string `db:"displayName" json:"address"`
|
|
}
|
|
|
|
// String returns string representation of location.
|
|
func (l *Location) String() string {
|
|
bytes, err := json.Marshal(l)
|
|
if err != nil {
|
|
// should never happen
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
return string(bytes)
|
|
}
|