peterbourgon / how-i-start-go

How I Start: Go
http://howistart.org/posts/go/1
143 stars 44 forks source link

small issues #6

Open karlhungus opened 6 years ago

karlhungus commented 6 years ago

Might be worth updating your post which is very good to note:

An example of how to call it now: https://github.com/karlhungus/dweeb/blob/0f1f795e9c301a89916e5a6d25d5e375de1aefdf/weather.go#L47

timothyjryan commented 6 years ago

I too noticed this problem. Looks like weathernderground requires a country code to explicitly resolve a city. For example there are Londons in several countries. Omitting the country code still generates a json file with all of the available city options, but this does not include the actual conditions fields, so you always get a zero for the temp.

The url should look something like this (for Japanese cities): url := "https://api.wunderground.com/api/" + w.apiKey + "/conditions/q/JP/" + city + ".json"

I can't say that I took the time to review the API docs to see if there is a way to have weatherunderground automatically pick the best one.