A simple command line calculator written in Go
Follow the instructions and copy the commands below to build the app
- Clone this repo
git clone https://github.com/ayushknath/calc-go.git- Move to the
srcdirectory and build the app
cd ./calc-go/src
go build -o ../build/calc- The executable is under the
builddirectory
cd ../build
./calc add 2 3The app has two modes
- Normal mode: Here you can perform simple calculations by specifying the operation and the arguments (numbers) to operate upon
- Interactive mode: Spins up a REPL where you can write "not-so-complex" expressions and get their result
Simple calculations can be done with built-in commands, each of which accept two arguments like:
./calc add 2 3for addition./calc sub 2 3for subtraction./calc mul 2 3for multiplication./calc div 2 3for division./calc exp 2 3for exponentiation
To enter the REPL, type ./calc -i. To quit the REPL, type quit
$ ./calc -i
Interactive mode
>> 2 + 3 * (8 - 4)
14.00
>> quit
$