summaryrefslogtreecommitdiff
path: root/weather.go
diff options
context:
space:
mode:
Diffstat (limited to 'weather.go')
-rw-r--r--weather.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/weather.go b/weather.go
index ab1f472..a55347c 100644
--- a/weather.go
+++ b/weather.go
@@ -27,12 +27,20 @@ type Current struct {
Sys Sys
ID int // City ID
Name string // City Name
- Cod int // Internal Parameter
+ Cod int `json:"-"` // bogus int/string
+ Message string
}
func (c Current) String() string {
- return fmt.Sprintf("%v: %v, %v, %v",
- c.Name, c.Weather[0], c.Main, c.Wind)
+ if c.Message != "" {
+ return c.Message
+ }
+ s := fmt.Sprintf("%v: ", c.Name)
+ for _, w := range c.Weather {
+ s += fmt.Sprintf("%v, ", w)
+ }
+ s += fmt.Sprintf("%v, %v", c.Main, c.Wind)
+ return s
}
type Coord struct {
@@ -47,14 +55,14 @@ func (c Coord) String() string {
type Cond int
type Weather struct {
- Cond Cond `json:"id"` // Station ID
+ ID Cond `json:"id"` // Station ID
Main string // Group of weather parameters
Description string // Weather condition within the group
Icon string // Weather con id
}
func (w Weather) String() string {
- return fmt.Sprint(w.Cond)
+ return fmt.Sprint(w.ID)
}
type Main struct {
@@ -75,10 +83,15 @@ func (m Main) String() string {
type Wind struct {
Speed float64 // Wind speed. Default meter/sec
Deg int // Wind direction, degrees (meteorogical)
+ Gust float64
}
func (w Wind) String() string {
- return fmt.Sprintf("wind: %v° %v m/s", w.Deg, w.Speed)
+ s := fmt.Sprintf("wind: %v° %v m/s", w.Deg, w.Speed)
+ if w.Gust != 0 {
+ s += fmt.Sprintf(" gust %v m/s", w.Gust)
+ }
+ return s
}
type Clouds struct {
@@ -90,7 +103,7 @@ func (c Clouds) String() string {
}
type Rain struct {
- Vol int `json:"3h"` // Rain volume for last 3 hours
+ Vol float64 `json:"3h"` // Rain volume for last 3 hours
}
func (r Rain) String() string {
@@ -101,7 +114,7 @@ func (r Rain) String() string {
}
type Snow struct {
- Vol int `json:"3h"` // Snow volume for last 3 hours
+ Vol float64 `json:"3h"` // Snow volume for last 3 hours
}
func (s Snow) String() string {