docs: Add package usage

Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
Tim Hårek Andreassen 2024-10-03 19:40:34 +02:00
parent 6b22e870a1
commit 7d256f0ca6
No known key found for this signature in database
GPG key ID: E59C7734F0E10EB5

View file

@ -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].