{"id":20119135,"url":"https://github.com/saro0307/calculator-using-golang","last_synced_at":"2026-07-18T02:39:02.145Z","repository":{"id":244983158,"uuid":"816912155","full_name":"saro0307/calculator-using-golang","owner":"saro0307","description":"functionalities of a calculator represented using Golang","archived":false,"fork":false,"pushed_at":"2024-07-05T13:39:44.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T21:45:47.188Z","etag":null,"topics":["calculator","calculator-app","calculator-application","golang","golang-application","golang-package"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saro0307.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-06-18T16:26:24.000Z","updated_at":"2024-07-05T13:39:48.000Z","dependencies_parsed_at":"2024-06-18T20:56:39.804Z","dependency_job_id":"5e81d98e-a3c9-4b16-8bfa-53f7fc4796de","html_url":"https://github.com/saro0307/calculator-using-golang","commit_stats":null,"previous_names":["saro0307/calculator-using-golang"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/saro0307/calculator-using-golang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saro0307%2Fcalculator-using-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saro0307%2Fcalculator-using-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saro0307%2Fcalculator-using-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saro0307%2Fcalculator-using-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saro0307","download_url":"https://codeload.github.com/saro0307/calculator-using-golang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saro0307%2Fcalculator-using-golang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35602804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-18T02:00:07.223Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["calculator","calculator-app","calculator-application","golang","golang-application","golang-package"],"created_at":"2024-11-13T19:14:29.653Z","updated_at":"2026-07-18T02:39:02.114Z","avatar_url":"https://github.com/saro0307.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\n## Calculator Using Golang\n\nThis project is a simple HTTP server written in Go that performs basic arithmetic operations (addition, subtraction, multiplication, and division) on two numbers provided in a JSON request. The server listens on port 8090.\n\n### Prerequisites\n\n- Go 1.13 or higher\n\n### Installation\n\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/saro0307/calculator-using-golang.git\n   ```\n2. Navigate to the project directory:\n   ```sh\n   cd calculator-using-golang\n   ```\n\n### Usage\n\n1. Build and run the server:\n   ```sh\n   go run main.go\n   ```\n   The server will start listening on `http://localhost:8090`.\n\n2. Send a POST request with a JSON payload to the server:\n   ```sh\n   curl -X POST http://localhost:8090/ -d '{\"num1\": 10, \"num2\": 5}' -H \"Content-Type: application/json\"\n   ```\n\n### Example\n\n**Request:**\n\n```json\n{\n  \"num1\": 10,\n  \"num2\": 5\n}\n```\n\n**Response:**\n\n```json\n{\n  \"add\": 15,\n  \"mul\": 50,\n  \"sub\": 5,\n  \"div\": 2\n}\n```\n\n### API Endpoint\n\n- **`POST /`**\n  - **Request Body:** JSON object with the fields `num1` and `num2`, both of which are float64.\n  - **Response Body:** JSON object with the results of addition (`add`), multiplication (`mul`), subtraction (`sub`), and division (`div`).\n\n### Code Explanation\n\n1. **Structs:**\n    - `numbers`: Represents the input JSON object with `num1` and `num2` as fields.\n    - `numsResponseData`: Represents the response JSON object with the results of the arithmetic operations.\n\n2. **Functions:**\n    - `process(numsdata numbers) numsResponseData`: Takes a `numbers` object as input and returns a `numsResponseData` object with the results of the arithmetic operations.\n    - `calc(w http.ResponseWriter, request *http.Request)`: HTTP handler function that decodes the JSON request, processes the numbers, and encodes the JSON response.\n\n3. **Main Function:**\n    - `main()`: Sets up the HTTP server to handle requests at the root endpoint (`\"/\"`) using the `calc` function.\n\n### Error Handling\n\nThe current implementation does not include extensive error handling. It is recommended to add checks for division by zero and ensure valid JSON payloads in production code.\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n### Acknowledgements\n\nThis simple arithmetic server was created as a learning project and is intended for educational purposes.\n\n---\n\nFeel free to contribute, report issues, or fork this repository for your own use!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaro0307%2Fcalculator-using-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaro0307%2Fcalculator-using-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaro0307%2Fcalculator-using-golang/lists"}