Go-Math CLI is a command-line tool designed to perform basic mathematical operations such as addition, subtraction, multiplication, division, square, square root, and percentage calculations. This project was created for educational purposes to explore Go programming, CLI development, and modular code organization. However, if you find it useful or want to extend its functionality, feel free to do so!
- Addition: Add two numbers.
- Subtraction: Subtract one number from another.
- Multiplication: Multiply two numbers with optional rounding.
- Division: Divide one number by another with optional rounding.
- Square: Calculate the square of a number.
- Square Root: Calculate the square root of a number.
- Percentage: Calculate a percentage of a given number.
Before installing the code make sure you have go installed on your system.
-
Clone the repository:
git clone https://github.com/sameer920/go-math.git cd go-math -
Build the project:
go build
-
Install the binary:
go install
Run the go-math command followed by the desired operation and its arguments. Below are some examples:
go-math add 5 10
# Output: Addition of 5 and 10 = 15go-math subtract 20 5
# Output: Subtracting 5 from 20 = 15go-math multiply 3 4
# Output: Multiplication of 3 and 4 = 12go-math divide 10 2
# Output: Division of 10 by 2 = 5go-math square 5
# Output: Square of 5 = 25go-math sqrt 16
# Output: Square root of 16 = 4go-math percent 200 10
# Output: 10% of 200 = 20cmd/: Contains all the CLI commands (e.g.,add,subtract,multiply, etc.).go-math.go: The entry point of the application.math.go: Core mathematical functions used by the CLI commands.
Since the project was created for educational value, I would probably not be maintaining it. If you want to use it in anyway, you can fork or clone the repo and use it however you want to.
This project is released into the public domain under the Unlicense. You are free to use, modify, publish, and distribute this software for any purpose, without any restrictions.
For more details, see the LICENSE file.
This project was created for educational purposes and may not be production-ready. Use it at your own discretion. While I have taken care to ensure the code is functional, there may still be edge cases or bugs. If you encounter any issues, feel free to report them or submit a fix.
Special thanks to the developers of the Cobra CLI library for making CLI development in Go so seamless.
I would also like to acknowledge this amazing article from JetBrains that I followed initially to make this project.
Happy coding! 😊