Skip to content

Commit 74e64db

Browse files
committed
split up api response into separate types
1 parent 29582b3 commit 74e64db

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

‎openweathermap.go‎

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,59 @@
11
package openweathermap
22

3+
/*
4+
Define API response fields
5+
*/
36
type OpenWeatherMap struct {
47
API_KEY string
58
}
69

10+
type coord struct {
11+
lon int
12+
lat int
13+
}
14+
15+
type weather struct {
16+
id int
17+
main string
18+
description string
19+
}
20+
21+
type wind struct {
22+
speed float64
23+
deg float64
24+
}
25+
26+
type clouds struct {
27+
all int
28+
}
29+
30+
type rain struct {
31+
threehr int `json:"3h"`
32+
}
33+
34+
type visibility string
35+
36+
type dt int
37+
38+
type id int
39+
40+
type name string
41+
42+
type main struct {
43+
temp float64
44+
pressure int
45+
humidity int
46+
temp_min float64
47+
temp_max float64
48+
}
49+
750
type forecastResponse struct {
851
city struct {
952
id int
1053
name string
1154
}
12-
coord struct {
13-
long float64
14-
lat float64
15-
}
55+
coord
56+
1657
country string
1758
cnt int
1859
list [] struct {
@@ -23,11 +64,8 @@ type forecastResponse struct {
2364
temp_max float64
2465
humidity float64
2566
}
26-
weather [] struct {
27-
id int
28-
main string
29-
description string
30-
}
67+
weather []weather
68+
3169
clouds struct {
3270
all int
3371
}

0 commit comments

Comments
 (0)