From a2eaa8cd75a5b167cf6dbd3dd8c6414cc4239f11 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 9 Jul 2015 18:26:28 +0200 Subject: Readd metar --- weather.go | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 weather.go (limited to 'weather.go') diff --git a/weather.go b/weather.go deleted file mode 100644 index ed4a139..0000000 --- a/weather.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "io/ioutil" - "net/http" - "strings" - "errors" -) - -const ( - noaa = `http://weather.noaa.gov/pub/data/observations/metar/` - noaaDecoded = noaa + `decoded/` - noaaStations = noaa + `stations/` -) - -var notFound = errors.New("not found") - -func FetchMetar(s string) ([]string, error) { - loc := noaaStations + strings.ToUpper(s[:4]) + ".TXT" - resp, err := http.Get(loc) - if err != nil { - return nil, err - } - defer resp.Body.Close() - if resp.StatusCode == http.StatusNotFound { - return nil, notFound - } - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - return strings.Split(strings.TrimSpace(string(body)), "\n"), nil -} -- cgit v1.2.3