From 7d256f0ca63d7a589e39bdd579fd8c89ffe05b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20H=C3=A5rek=20Andreassen?= Date: Thu, 3 Oct 2024 19:40:34 +0200 Subject: [PATCH] docs: Add package usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim HĂ„rek Andreassen --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index abfd9c9..87ef205 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [yr] -Get the weather delivered to your command-line. +Get the weather delivered to your command-line, or use as a Go package. The project uses [Meteorologisk institutt]'s public API, [`LocationForecast`], and [OpenStreetMap]'s [Nominatim] API. @@ -30,6 +30,20 @@ yr forecast "new york" --web yr now "new york" --web ``` +### As a package + +```go +import "git.sr.ht/~timharek/yr/yr" + +func weather() { + y := yr.New() + + now := y.Now("bergen") + + // Use the data +} +``` + ## Contributing Anyone can contribute to [yr]. Please refer to the [contribution guidelines].