This Go project fetches and displays the current weather information for the location associated with your IP address. It utilizes two external APIs:
- A geo-location API to determine your city and country based on your IP address.
- A weather API to fetch the current weather for the detected location.
Ensure that you have Go installed on your machine. You can verify the installation by running:
go version
git clone https://github.com/scotty-c/weather.git
cd weather
You can build the project using the Go build tool:
go build -o weather
After building the project, you can run the application using:
./weather
This will print the current weather information for your location.
By default, the application uses the following APIs:
- Geo-location API:
https://api.seeip.org/geoip
- Weather API:
https://v3.wttr.in/
The application will fetch your city and country based on your IP address and then fetch the current weather for that location.
Test City: Clear skies
This output shows the weather information for the detected location.
weather/
│
├── main.go # The main application logic
├── main_test.go # Unit tests for the application
├── README.md # Project documentation
-
Geo-location API:
- URL:
https://api.seeip.org/geoip
- This API returns the city and country based on the user's IP address.
- URL:
-
Weather API:
- URL:
https://v3.wttr.in/<city>+<country>?format=%c+%t
- This API returns the current weather for the specified city and country.
- URL:
Unit tests are provided in the main_test.go
file. The tests use mock servers to simulate the external APIs.
You can run the tests using the following command:
make test
This command will execute all the tests and display the results.
Contributions are welcome! If you would like to contribute to the project, please fork the repository, create a new branch for your feature or bugfix, and submit a pull request. Make sure to include tests for any new functionality.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for more details.