summaryrefslogtreecommitdiff
path: root/weather.go
diff options
context:
space:
mode:
Diffstat (limited to 'weather.go')
-rw-r--r--weather.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/weather.go b/weather.go
index b0ca2da..961b418 100644
--- a/weather.go
+++ b/weather.go
@@ -204,6 +204,7 @@ func main() {
var err error
var id string
var url string
+ var parsefunc func([]byte) []Weather
var resp *http.Response
var weather []Weather
@@ -213,9 +214,11 @@ func main() {
case "bbc":
id = bbcdefid
url = bbcurl
+ parsefunc = processBBC
case "metoffice":
id = metdefid
url = meturl
+ parsefunc = processMet
default:
log.Fatalf("data source %s not supported; use either 'bbc' or 'metoffice'\n", *src)
}
@@ -234,11 +237,7 @@ func main() {
}
b, err := ioutil.ReadAll(resp.Body)
- if *src == "bbc" {
- weather = processBBC(b)
- } else {
- weather = processMet(b)
- }
+ weather = parsefunc(b)
for _, w := range weather {
fmt.Printf("%s %s ", w.date, w.time)