Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/renanmav/goexpert-ceptemperature-gcr
Deployed to Google Cloud Run (GCR)
https://github.com/renanmav/goexpert-ceptemperature-gcr
exercise golang google-cloud-run
Last synced: about 2 months ago
JSON representation
Deployed to Google Cloud Run (GCR)
- Host: GitHub
- URL: https://github.com/renanmav/goexpert-ceptemperature-gcr
- Owner: renanmav
- Created: 2024-09-22T20:52:56.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-11-07T00:13:22.000Z (2 months ago)
- Last Synced: 2024-11-07T01:21:03.398Z (2 months ago)
- Topics: exercise, golang, google-cloud-run
- Language: Go
- Homepage: https://go-expert-cep-temperature-gcr-608943233137.us-central1.run.app/weather?cep=01001000
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GoExpert-CEPTemperature-GCR
This project is a Go-based web service that provides temperature information for a given CEP (Postal Code) in Brazil. It uses the [ViaCEP API](https://viacep.com.br/) to get location information and the [WeatherAPI](https://www.weatherapi.com/) to fetch temperature data.
The service is designed to be deployed on [Google Cloud Run](https://cloud.google.com/run).
## Features
- Fetch location information using CEP (Brazilian Postal Code)
- Retrieve current temperature for the location
- Convert temperature to Celsius, Fahrenheit, and Kelvin
- Configurable using environment variables
- Designed with Clean Architecture principles## Prerequisites
- Go 1.19 or later
- WeatherAPI API key (sign up at https://www.weatherapi.com)## Setup
1. Clone the repository:
```
git clone https://github.com/renanmav/GoExpert-CEPTemperature-GCR.git
cd GoExpert-CEPTemperature-GCR
```1. Create a `.env` file from the provided `.env.example`:
```
cp .env.example .env
```1. Edit the `.env` file and set your WeatherAPI key:
```
WEATHER_API_KEY=your_api_key_here
```1. Install dependencies:
```
go mod tidy
```## Running the Application
To run the application locally:
```
go run cmd/main.go
```The server will start on the port specified in your `.env` file (default is 8080).
## API Usage
To get weather information for a CEP, make a GET request to the `/weather` endpoint with the `cep` query parameter:
```bash
curl http://localhost:8080/weather?cep=01001000
```The response will be a JSON object containing the city name and temperature in Celsius, Fahrenheit, and Kelvin.
## Deployment to Google Cloud Run
1. Build the Docker image:
```
docker build -t gcr.io/goexpert-436420/go-expert-cep-temperature-gcr .
```2. Push the image to Google Container Registry:
```
docker push gcr.io/goexpert-436420/go-expert-cep-temperature-gcr
```3. Deploy to Cloud Run:
```
gcloud run deploy --image gcr.io/goexpert-436420/go-expert-cep-temperature-gcr --platform managed
```Make sure to set the `WEATHER_API_KEY` environment variable in your Cloud Run configuration.