summaryrefslogtreecommitdiff
path: root/metar.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-09 18:35:04 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-09 18:35:04 +0200
commitc3b81b0f04f35c8be63b8daff04829382050644a (patch)
treef6a973df89362f9f674cb6708b59f92057da4df9 /metar.go
parenta2eaa8cd75a5b167cf6dbd3dd8c6414cc4239f11 (diff)
Update weather
Diffstat (limited to 'metar.go')
-rw-r--r--metar.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/metar.go b/metar.go
index 581a158..c19fe6d 100644
--- a/metar.go
+++ b/metar.go
@@ -1,10 +1,10 @@
package main
import (
+ "errors"
"io/ioutil"
"net/http"
"strings"
- "errors"
)
const (
@@ -15,8 +15,8 @@ const (
var notFound = errors.New("not found")
-func FetchMetar(s string) ([]string, error) {
- loc := noaaDecoded + strings.ToUpper(s[:4]) + ".TXT"
+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
@@ -31,3 +31,11 @@ func FetchMetar(s string) ([]string, error) {
}
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)
+}