Calling the OpenWeather API in Go
slicker.me·4d·
Discuss: r/golang
🐹Go
Preview
Report Post

How to Call the OpenWeather API in Go

This tutorial walks you through building a small Go program that fetches weather data from the OpenWeather API. You’ll also learn how to securely store your API key using an environment variable — a best practice for any real-world application. We picked OpenWeather just because it’s easy. Once you learn APIs, you can use other useful ones, that provide stock market or government data.

First, you’ll need to obtain a free OpenWeatherMap API key — sign up at OpenWeatherMap and get an API key, then replace the string your_api_key_here in the script.

The key is generated immediately, but it takes a couple of hours before they activate it. You will see your key on the ‘API Keys’ tab (it is a st…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help