summaryrefslogtreecommitdiff
path: root/metar.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-20 16:48:35 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-20 16:48:35 +0200
commit28d101636212e8e539512916c4587ea8bf657ddb (patch)
tree99f465941219ff12b3dc4192387cefeeab160d3c /metar.go
parentb0f17fc12e0d3698cfa872d13a74f2c3aecbea62 (diff)
Add weather
Diffstat (limited to 'metar.go')
-rw-r--r--metar.go41
1 files changed, 0 insertions, 41 deletions
diff --git a/metar.go b/metar.go
deleted file mode 100644
index c19fe6d..0000000
--- a/metar.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package main
-
-import (
- "errors"
- "io/ioutil"
- "net/http"
- "strings"
-)
-
-const (
- noaa = `http://weather.noaa.gov/pub/data/observations/metar/`
- noaaDecoded = noaa + `decoded/`
- noaaStations = noaa + `stations/`
-)
-
-var notFound = errors.New("not found")
-
-func fetchMetar(base, station string) ([]string, error) {
- loc := base + strings.ToUpper(station[: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
-}
-
-func MetarDecoded(s string) ([]string, error) {
- return fetchMetar(noaaDecoded, s)
-}
-
-func MetarStation(s string) ([]string, error) {
- return fetchMetar(noaaStations, s)
-}