This is a simple calculator made in Go (https://go.dev/).
To use it you must have Go installed in your computer, in Linux you can easy install using snap:
sudo snap install go --classic
or
sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
than you must add the Go path to your .bashrc or .zshrc file:
export PATH=$PATH:/usr/local/go/bin
verify if the Go is installed:
go version
For other languagues, check the Go website:
go run main.go
http://localhost:8080
results will be printed in the web browser.
or run in terminal:
go run main.go 5 + 3
8
- The First number, ex: 10
- The operator (+, -, "*", /).
- The second number, ex: 2
It checks if the arguments are valid and perform the operations.
Note: For multiplication, you must input as: "*" or *, or the command line will output an error.
go build name_of_binary.go
go build -o name_of_binary.exe name_of_binary.go
./calculator 10 + 2
result: 12
calculator.exe 10 + 2
result: 12
GOOS=linux GOARCH=amd64 go build -o calculator-linux calculator.go
GOOS=windows GOARCH=amd64 go build -o calculator.exe calculator.go
GOOS=darwin GOARCH=amd64 go build -o calculator-mac calculator.go
Contributions are always welcome!
See CONTRIBUTING.md
to learn how to get started.