Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

GointermediatecliAI generated

CLI Weather Dashboard

Build a weather dashboard that runs in the terminal, written in Go: search for a city and see a full-screen display with panels for the current conditions, an hourly temperature chart for the next day, and a 7-day forecast, refreshing automatically every few minutes. Data comes from the free Open-Meteo API (no key needed) through net/http, and responses are cached in a local file so repeat lookups are instant. The interface is drawn with a terminal UI library (termui, or a more actively maintained one such as tview or Bubble Tea). You'll learn calling REST APIs with timeouts, unmarshaling JSON into structs, laying out a terminal interface, handling keyboard input, tickers for refreshing, and caching.

Estimate
~11h
Steps
6
Completed by
0
Proposed by
codeseed.app

net/http · encoding/json · termui or tview · Open-Meteo

Project roadmap

  1. 01

    Build the API client

    ~2h

    Create a Go module and a weather package with a client using an http.Client with a timeout. Implement two calls to Open-Meteo: geocoding (city name to coordinates, with country and region) and forecast (current conditions, 24 hourly temperatures and 7 daily highs, lows and weather codes). Build URLs with net/url so city names are encoded correctly, and return wrapped errors for failed requests. Done when: a small test program prints the forecast for a city.

  2. 02

    Unmarshal the responses

    ~1.5h

    Define structs with json tags matching the parts of the responses you use, and convert Open-Meteo's parallel arrays (times and values) into slices of structs such as HourlyPoint and DailyForecast. Parse times with time.Parse, and map weather codes to descriptions. Write tests with saved JSON files. Done when: the tests decode sample responses into correct structs.

  3. 03

    Build the terminal dashboard

    ~3h

    Using a terminal UI library (termui as the stack suggests, or tview or Bubble Tea since termui is no longer maintained), lay out panels: the city and current conditions, a line chart of the next 24 hours' temperatures, a table of the 7-day forecast, and a status bar with the last update time and key help. Resize the layout when the terminal is resized. Done when: the dashboard shows a city's weather in well-arranged panels.

  4. 04

    Add search and caching

    ~2h

    Add a search box (opened with /) that looks up cities and lets the user choose from the matches. Cache forecast responses in a JSON file in the user's cache folder (os.UserCacheDir) with the time they were fetched, reusing them for 10 minutes, and remember recent cities for quick switching with the number keys. Show cached data with a note when the network fails. Done when: searching works, and repeat lookups load instantly from the cache.

  5. 05

    Refresh automatically

    ~1h

    Use a time.Ticker to refresh the current city on a configurable interval (a -refresh flag, default 5 minutes) in a goroutine, sending results back to the UI safely (through a channel or the library's update mechanism), and let r force a refresh. Stop the ticker and exit cleanly with q or Ctrl+C. Done when: the dashboard updates by itself, and quitting leaves the terminal clean.

  6. 06

    Test it

    ~1.5h

    Write tests using httptest.Server to fake Open-Meteo: geocoding with no results, forecast parsing, timeouts, and the cache (fresh, stale and corrupted files). Keep the UI thin so the logic can be tested without a terminal. Done when: go test ./... passes.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~11h · 6 steps

Tech stack

net/httpencoding/jsontermui or tviewOpen-Meteo