summaryrefslogtreecommitdiff
path: root/weather.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-09 18:26:28 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-09 18:26:28 +0200
commita2eaa8cd75a5b167cf6dbd3dd8c6414cc4239f11 (patch)
treec80914e89704d8c88464f379db20c828c450a6a3 /weather.go
parent62234560e59929ddde351750434a00d926d09288 (diff)
Readd metar
Diffstat (limited to 'weather.go')
-rw-r--r--weather.go33
1 files changed, 0 insertions, 33 deletions
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
-}