The goal of this project is to develop a system in Go that takes a postal code as input, identifies the city, and returns the current weather (temperature in Celsius, Fahrenheit, and Kelvin). This system will be deployed on Google Cloud Run.
- The system must accept a valid 8-digit zip code.
- After receiving the zip code, the system must identify the corresponding location and return temperatures formatted in Celsius, Fahrenheit and Kelvin.
- The system must respond to the following scenarios: -- If successful: Respond with HTTP code 200 and a response body containing the temperatures in the three scales. -- In case of invalid zip code (incorrect format): Respond with HTTP code 422 and an "invalid zip code" error message. -- In case of zip code not found: Respond with HTTP code 404 and an error message below "can not find zipcode".
- The system deployment must be carried out on Google Cloud Run.
- Using the viaCEP API to find the desired location in the provided zip code.
- Use of the WeatherAPI API to query desired temperatures.
- Application of formulas for temperature conversion between Celsius, Fahrenheit and Kelvin scales.
- Programming Language: Go
- External APIs: viaCEP and WeatherAPI
- Hosting: Google Cloud Run
- Containerization: Docker
- Go 1.16+ installed
- Docker installed (for running the project via Docker)
- An internet connection to access external APIs (viaCEP and WeatherAPI)
WEATHER_API_KEY
: API key for the WeatherAPI service.
- Clone the repository
- Run the following command to start the application:
go run main.go
- Access the following URL in your browser or using an API client (such as Postman):
http://localhost:8080/?cep={zipCode}
Replace {zipCode}
with the desired zip code.
- Run the following command to build the Docker image:
docker build -t get-temperature-by-zip-code .
- Run the following command to start the application:
docker run -p 8080:8080 get-temperature-by-zip-code
- Access the following URL in your browser or using an API client (such as Postman):
http://localhost:8080/?cep={zipCode}
Replace {zipCode}
with the desired zip code.
- Run the following command to start the application:
docker-compose up
- Access the following URL in your browser or using an API client (such as Postman):
http://localhost:8080/?cep={zipCode}
Replace {zipCode}
with the desired zip code.
- Run the following command to start the tests:
go test ./...
This project is hosted on Google Cloud Run. You can access the application using the following URL:
https://get-weather-cl2xj3spza-uc.a.run.app/?cep={zipCode}
Replace {zipCode}
with the desired zip code.
- 11010-020 (Santos/SP)
- 13484-015 (Limeira/SP)
- 17560-015 (Vera Cruz/SP)
- 80220-000 (Curitiba/PR)