Skip to content

Commit

Permalink
fix config var name in wwo backend
Browse files Browse the repository at this point in the history
  • Loading branch information
schachmat committed Mar 6, 2016
1 parent 41b0c32 commit d9e527f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions backends/worldweatheronline.com.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ type wwoCoordinateResp struct {
}

type wwoConfig struct {
wwoApiKey string
wwoLanguage string
apiKey string
language string
}

const (
Expand Down Expand Up @@ -249,8 +249,8 @@ func wwoUnmarshalLang(body []byte, r *wwoResponse, lang string) error {
}

func (c *wwoConfig) Setup() {
flag.StringVar(&c.wwoApiKey, "wwo-api-key", "", "wwo backend: the api `KEY` to use")
flag.StringVar(&c.wwoLanguage, "wwo-lang", "en", "wwo backend: the `LANGUAGE` to request from wwo")
flag.StringVar(&c.apiKey, "wwo-api-key", "", "wwo backend: the api `KEY` to use")
flag.StringVar(&c.language, "wwo-lang", "en", "wwo backend: the `LANGUAGE` to request from wwo")
}

func getCoordinatesFromAPI(queryParams []string, c chan *iface.LatLon) {
Expand Down Expand Up @@ -288,10 +288,10 @@ func (c *wwoConfig) Fetch(loc string, numdays int) iface.Data {
var ret iface.Data
coordChan := make(chan *iface.LatLon)

if len(c.wwoApiKey) == 0 {
if len(c.apiKey) == 0 {
log.Fatal("No API key specified. Setup instructions are in the README.")
}
params = append(params, "key="+c.wwoApiKey)
params = append(params, "key="+c.apiKey)

if len(loc) > 0 {
params = append(params, "q="+url.QueryEscape(loc))
Expand All @@ -302,8 +302,8 @@ func (c *wwoConfig) Fetch(loc string, numdays int) iface.Data {

go getCoordinatesFromAPI(params, coordChan)

if c.wwoLanguage != "" {
params = append(params, "lang="+c.wwoLanguage)
if c.language != "" {
params = append(params, "lang="+c.language)
}

res, err := http.Get(wwoWuri + strings.Join(params, "&"))
Expand All @@ -316,12 +316,12 @@ func (c *wwoConfig) Fetch(loc string, numdays int) iface.Data {
log.Fatal(err)
}

if c.wwoLanguage == "" {
if c.language == "" {
if err = json.Unmarshal(body, &resp); err != nil {
log.Println(err)
}
} else {
if err = wwoUnmarshalLang(body, &resp, c.wwoLanguage); err != nil {
if err = wwoUnmarshalLang(body, &resp, c.language); err != nil {
log.Println(err)
}
}
Expand Down

0 comments on commit d9e527f

Please sign in to comment.