diff options
Diffstat (limited to 'weather.go')
-rw-r--r-- | weather.go | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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) |