This project demonstrates a simple client-server interaction in Go to fetch exchange rates and store them in a SQLite database.
The project consists of two main components:
client.go: A client application that fetches the current USD to BRL exchange rate from the server and saves it to a file.server.go: A server application that fetches the current exchange rate from an external API, stores it in a SQLite database, and provides it to clients upon request.
- Go (Golang)
- SQLite
-
Clone the repository:
git clone https://github.com/andrelmm/go-client-server-api-challenge.git cd go-client-server-api-challenge -
Install dependecies:
go mod tidy
-
Run the server:
go run server.go
-
In a separate terminal, run the client:
go run client.go
The project follows this structure:
client.go: The client application code that fetches the exchange rate from the server and saves it to a file.server.go: The server application code that fetches the exchange rate from an external API, stores it in the database, and serves client requests.cotation.go: The SQLite database file where the exchange rates are stored.cotacao.txt: The text file where the fetched exchange rate is saved by the client.README.MD: This documentation file.