A simple terminal calculator written in Go. It evaluates basic mathematical expressions (addition, subtraction, multiplication, division) with operator precedence and supports using the last result in new expressions.
- Parses and evaluates simple math expressions
- Interactive terminal usage
- Operator precedence handling (
*and/before+and-) - Supports reusing the last result in new calculations
Download the latest release from the Releases page, extract it, and run:
./calqType your expressions and see the results.
Press q and Enter or Ctrl+C to exit.
To develop, build, or run the project locally using Docker and Makefile (no Go installation required):
- Clone the repository:
git clone https://github.com/gabrieldeespindula/calq.git
cd calq- To run the project:
make runThese commands run Go inside a Docker container to provide a clean and reproducible environment.
To run tests and check code coverage locally, use:
make testRun tests and generate coverage.out
make coverageRun tests, generate and open coverage.html
cmd/calq/main.go: application entrypointinternal/calculator/: calculator logic (tokenization, evaluation, operations)Dockerfile: Docker image for development environmentdocker-compose.yml: Docker service config for developmentMakefile: shortcuts for building and running using Docker
- Go 1.22
- Docker (for isolated development environment)
- Makefile (command automation)
This GIF shows how the calq CLI tool works in a terminal environment:
You can generate a local (snapshot) release to test the artifacts built by GoReleaser without publishing them to GitHub. This helps validate the build process and binary structure before creating an actual release.
- Docker
docker-compose
make release-localThis will use the goreleaser/goreleaser container defined in docker-compose.yml to generate the binaries locally inside the dist/ folder.
Contributions are welcome! Please open issues for bugs or feature requests, and submit pull requests for review.
MIT License © Gabriel de Espindula
Gabriel de Espindula – @gabrieldeespindula
This project was created as a personal learning exercise to deepen my understanding of Go, building from scratch a simple calculator with expression parsing and evaluation. While libraries exist that solve this problem more comprehensively, this project focuses on educational purposes.
