diff options
author | Nick White <git@njw.name> | 2021-02-05 13:46:40 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-02-05 13:46:40 +0000 |
commit | 8cfb6dbbf6ea6cea1e90f49b005d504d91d48894 (patch) | |
tree | 112ec1b2ad8e49e6c2311ae5fb432d91c3655fe8 | |
parent | 3413df247aee70fc9ba217dfaa24bb217fff4248 (diff) | |
download | weather-8cfb6dbbf6ea6cea1e90f49b005d504d91d48894.tar.bz2 weather-8cfb6dbbf6ea6cea1e90f49b005d504d91d48894.zip |
Clean up parsing a little
-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) |