Skip to content

vincent-petithory/go-openweathermap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Go Openweathermap

This program fetches the current weather from Open Weather Map and format it.

Formatting is done with a Go template using the data structure main.CurrentWeather.

Usage

Here's an example which will print something like:

Paris 25°C Scattered clouds

Code:

echo '{{.Name}} {{temp .Main.Temp.ToC}}°C {{(index .Weather 0).Description}}' | go-openweathermap --once 2988507

A bit more complex with a weather unicode char:

Paris 25°C Scattered clouds ☁

Code:

echo '{{.Name}} {{temp .Main.Temp.ToC}}°C {{(index .Weather 0).Description}}|{{(index .Weather 0).Id}}' | go-openweathermap --fetch-delay 10m 2988507 \
| while read line; do
	text=$(echo "$line" | cut -f1 -d'|')
	condition_code=$(echo "$line" | cut -f2 -d'|')
	icon='?'
	case $condition_code in
		200|201|202|210|211|212|221|230|231|232)
		# thunderstorm
		icon=☂
		;;
		300|301|302|310|311|312|313|314|321)
		# drizzle
		icon=☂
		;;
		500|501|502|503|504|511|520|521|522|531)
		# rain
		icon=☂
		;;
		600|601|602|611|612|615|616|620|621|622)
		icon=☃
		;;
		801|802|803|804)
		icon=☁
		;;
		800)
		icon=☀
		;;
		esac
	echo $text $icon
done

About

A program to retrieve weather on http://openweathermap.org/

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages