Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pansani/go-fastest-api-response
https://github.com/pansani/go-fastest-api-response
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pansani/go-fastest-api-response
- Owner: pansani
- Created: 2024-07-01T17:14:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-02T21:25:46.000Z (5 months ago)
- Last Synced: 2024-07-18T05:36:50.481Z (4 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-fastest-api-response
This project is a challenge to fetch the fastest response between two different APIs using multithreading in Go. The two requests are made simultaneously, and the result of the fastest request is displayed on the command line.
## Description
The project makes simultaneous requests to the following APIs:
- [BrasilAPI](https://brasilapi.com.br/api/cep/v1/01153000)
- [ViaCEP](http://viacep.com.br/ws/01153000/json/)The fastest response is displayed on the command line with the address details and which API sent it. If the response time exceeds 1 second, a timeout error is displayed.
## How to Use
### Prerequisites
- [Go](https://golang.org/dl/) installed.
### Installation
Clone the repository:
```sh
git clone https://github.com/pansani/go-fastest-api-response.git
cd go-fastest-api-response
```Initialize the Go module:
```sh
go mod init github.com/pansani/go-fastest-api-response
```### Running
Run the project:
```sh
go run main.go
```## Project Structure
```go
go-fastest-api-response/
├── go.mod
└── main.go
```### `main.go`
This file contains the main logic of the project. It makes simultaneous requests and displays the fastest result or a timeout error.
## Author
- João Mendonça - [pansani](https://github.com/pansani)