{"id":25023170,"url":"https://github.com/pansani/go-exchange-rates","last_synced_at":"2025-03-30T12:44:50.700Z","repository":{"id":275689106,"uuid":"926877072","full_name":"pansani/go-exchange-rates","owner":"pansani","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-04T02:29:17.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T03:24:00.738Z","etag":null,"topics":["golang","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pansani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-04T02:24:00.000Z","updated_at":"2025-02-04T02:36:11.000Z","dependencies_parsed_at":"2025-02-04T03:34:02.396Z","dependency_job_id":null,"html_url":"https://github.com/pansani/go-exchange-rates","commit_stats":null,"previous_names":["pansani/go-exchange-rates"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pansani%2Fgo-exchange-rates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pansani%2Fgo-exchange-rates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pansani%2Fgo-exchange-rates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pansani%2Fgo-exchange-rates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pansani","download_url":"https://codeload.github.com/pansani/go-exchange-rates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246320131,"owners_count":20758407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","unit-testing"],"created_at":"2025-02-05T14:37:02.685Z","updated_at":"2025-03-30T12:44:50.674Z","avatar_url":"https://github.com/pansani.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Exchange Rate \n\nThis project is a simple Go application for fetching USD to BRL exchange rates from an external API, storing the rates in a SQLite database, and exposing an endpoint to retrieve the latest rate.\n\n---\n\n## Features\n\n- **API Integration**: Fetches USD to BRL exchange rates from `https://economia.awesomeapi.com.br/json/last/USD-BRL`.\n- **SQLite Database**: Stores the exchange rates locally.\n- **REST Endpoint**: Provides an endpoint (`/cotacao`) to retrieve the latest rate.\n- **Unit Tests**: Includes comprehensive tests for database operations and API handlers.\n\n---\n\n## Project Structure\n\n```\nclient-server-full-cycle/\n├── client/\n│   └── client.go          # Placeholder for potential client-side logic\n├── server/\n│   ├── server.go          # Main server logic and `/cotacao` handler\n│   ├── server_test.go     # Unit tests for server.go\n├── app.db                 # SQLite database (created during runtime)\n├── cotacao.txt            # Sample output file\n├── go.mod                 # Module dependencies\n├── go.sum                 # Dependency checksums\n└── README.md              # Project documentation\n```\n\n---\n\n## Prerequisites\n\n- **Go**: Install the latest version of Go from [golang.org](https://golang.org/dl/).\n- **SQLite3**: Ensure SQLite3 is installed on your system.\n\n---\n\n## Installation\n\n1. Clone this repository:\n   ```bash\n   git clone https://github.com/pansani/go-exchange-rates.git\n   cd go-exchange-rates\n   ```\n\n2. Install dependencies:\n   ```bash\n   go mod tidy\n   ```\n\n---\n\n## Usage\n\n1. Start the server:\n   ```bash\n   go run server/server.go\n   ```\n   The server will start on `http://localhost:8080`.\n\n2. Fetch the latest USD to BRL exchange rate:\n   ```bash\n   curl http://localhost:8080/cotacao\n   ```\n   The response will include the latest rate, e.g.:\n   ```\n   Dolar: 5.42\n   ```\n\n---\n\n## Testing\n\nRun unit tests with:\n```bash\ngo test ./...\n```\n\n### Included Tests:\n- **Database Operations**: Validates table creation, insertion, and data retrieval.\n- **API Handler**: Verifies `/cotacao` endpoint behavior with a mocked external API.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpansani%2Fgo-exchange-rates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpansani%2Fgo-exchange-rates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpansani%2Fgo-exchange-rates/lists"}