This is a simple Go-based CLI application that fetches and displays current and hourly weather forecast data for a specified location using the WeatherAPI.
- Fetches current weather details and displays temperature and condition.
- Provides an hourly forecast for the next 24 hours.
- Highlights forecast hours with a high chance of rain using colored output.
- Supports dynamic location input through command-line arguments.
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/Abhay-hack/weather-cli-app.git cd weather-cli-app
-
Install dependencies (e.g.,
fatih/color
):go get github.com/fatih/color
-
Build the application:
go build -o weather.exe
-
Set up your environment variable for the Weather API key:
- Replace
YOUR_API_KEY
with your WeatherAPI key:
export WEATHER_API_KEY=YOUR_API_KEY
- Replace
Run the CLI application with the following command:
./weather [location]
./weather "Lucknow"
If no location is provided, the default location "Lucknow" will be used.
- Displays the current weather condition and temperature of the specified location.
- Displays hourly forecast with temperature, chance of rain, and conditions.
- Uses colored text to highlight hours with a high chance of rain.
main.go
: The main file containing the logic to fetch and parse weather data from the WeatherAPI.
- fatih/color: A Go library used for colored output in the terminal.
To use this application, you need to sign up for a free API key at WeatherAPI and set it as an environment variable:
export WEATHER_API_KEY=your_api_key
- Go Language
- WeatherAPI
Contributions are welcome! Please fork this repository and submit a pull request with your changes.
Author: Abhay Gupta