A simple Weather App built with Go that utilizes an external API to fetch current weather data based on a given city.
- Retrieves current weather data from the Weather API
- Supports logging with Logrus Logrus
- Caching with Redis go-redis
- Environment configuration with Viper Viper
- Documentation with Swagger Swaggo
- Echo Framework Echo
- Go 1.16 or higher
- Redis
- Weather API key (sign up at https://www.weatherapi.com/ to obtain a key)
- Docker
-
Clone the repository:
git clone https://github.com/devfurkankizmaz/weather-app.git
-
Navigate to the project directory:
cd weather-app
-
Install the dependencies:
go mod download
-
Set up environment variables:
-
Create a
config.yml
file in the project root directory. -
Add the following variables to the
config.yml
file:SERVER_PORT: :7070 REDIS_ADDRESS: localhost:6379 REDIS_PASS: REDIS_DB: 0 REDIS_EXPIRY_MIN: 30 CONTEXT_TIMEOUT_SEC: 10 API_KEY: apikey API_URL: api.weatherapi.com/v1/current.json
-
Replace
<your-weather-api-key>
with your actual Weather API key. -
Replace
<redis-address>
,<redis-password>
,<redis-database>
with your Redis server information
-
Run the application
make dev make run
-
Open your web browser and navigate to
localhost:7070/docs/index.html
to access the Swagger documentation.
- Open your web browser and navigate to
localhost:7070/weather
. - Append the
city
query parameter to the URL, for example:localhost:7070/weather?city=Istanbul
orlocalhost:7070/weather?city=New%York
- The application will fetch the current weather data for the specified city and display it
Contributions are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request.