(deprecated) CLI and Go weather package
This repository has been archived on 2026-09-09. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Go 98.8%
  • Makefile 1.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Tim Hårek Andreassen 8cf9faa55b build: Move module path to src.timharek.no/tim/yr
git.sr.ht is being decommissioned. The Forgejo instance serves the
go-import meta tag, so tag-based 'go get' keeps working under the new
path. Docs updated to match.
2026-09-09 21:55:45 +02:00
cmd/yr build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00
internal lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
pkg lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
vhs Update vhs 2025-06-17 22:41:30 +02:00
.build.yml build: Use go test 2025-06-17 22:41:35 +02:00
.golangci.toml lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
CLAUDE.md build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00
CONTRIBUTING.md build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00
direction.go lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
direction_test.go direction: Lower-case consts 2026-02-12 21:37:58 +01:00
go.mod build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00
go.sum lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
go.tool.mod build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00
go.tool.sum lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
LICENSE.md chore: Add license 2024-09-29 19:21:46 +02:00
Makefile lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
README.md build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00
symbol.go lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
symbol_test.go formatting 2026-01-14 21:03:09 +01:00
uv.go lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
uv_test.go yr: Add UV 2026-02-13 14:34:49 +01:00
wind.go lint: Upgrade golangci-lint and fix all issues 2026-02-21 15:10:00 +01:00
wind_test.go yr: Add Beaufort scale 2026-02-13 21:54:45 +01:00
yr.go build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00
yr_test.go build: Move module path to src.timharek.no/tim/yr 2026-09-09 21:55:45 +02:00

Please use lyn instead. This project was renamed.

yr

demo

Get the weather delivered to your command-line, or use as a Go package, without the need for an API key!

The project uses Meteorologisk institutt's public API, LocationForecast, and OpenStreetMap's Nominatim API.

Install CLI

Using go:

go install src.timharek.no/tim/yr/cmd/yr@latest

Using Homebrew

brew tap timharek/tap
brew install yr

Adding more methods in the future. Help is wanted to achieve the best coverage.

Using pre-compiled binary

Select the version you want to install available releases and download it and add it to your bin or something similar.

Example:

wget https://src.timharek.no/tim/yr/releases/download/<release>/yr-<version>-linux-amd64.tar.gz
tar xf yr-<version>-linux-amd64.tar.gz
cd yr-<version>
cp yr /usr/local/bin

Configuration

yr uses a TOML config file located at $XDG_CONFIG_HOME/yr.toml (defaults to ~/.config/yr.toml on Linux/macOS). You can set a default location and preferences so you don't have to specify them every time.

Example yr.toml:

use_utc = false
show_uv = false
show_beaufort = true
show_dewpoint = false
show_humidity = true
temperature_format = "celsius"

[location]
name = "Bergen, Norway"
longitude = 5.3221
latitude = 60.3913

With a default location configured, you can run commands without specifying a location:

yr now
yr forecast
yr today

Usage

# Get help
yr --help

# Current forecast for location
yr now bergen

# Or with a space
yr now "new york"

# Use default location from config
yr now

# Forecast for multiple hours
yr forecast "new york"

# Forecast for next 5 hours
yr forecast "new york" -i 5

# Today's weather, or at a specific hour
yr today bergen
yr today bergen 14

# Tomorrow's weather at a specific hour
yr tomorrow bergen 08

# Include UV index
yr now bergen --uv

# Show Beaufort scale description alongside wind
yr now bergen --beaufort

# Temperature in Fahrenheit
yr now bergen --format fahrenheit

# Open forecast in your web browser
yr forecast "new york" --web

# Open now in your web browser
yr now "new york" --web

# View current config
yr config

As a package

go get src.timharek.no/tim/yr
import "src.timharek.no/tim/yr"

func weather() {
  client, err := yr.New()
  if err != nil {
    panic(err)
  }
  now := client.Now("bergen")

  // Use the data
}

Similar projects

Contributing

Anyone can contribute to yr. Please refer to the contribution guidelines.

Send patches to the report bugs on the issue tracker.