Skip to content

Latest commit

 

History

History
142 lines (85 loc) · 2.19 KB

README.md

File metadata and controls

142 lines (85 loc) · 2.19 KB

SANTANDER_GIT_CALCULATOR

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:

Install or Run

Run direct from command line:

For the web interface:

  go run main.go

Open your browser and access:

  http://localhost:8080

results will be printed in the web browser.

or run in terminal:

  go run main.go 5 + 3

Result:

  8

The program takes 3 arguments from the command line:

 - 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.

Compilation

Linux or Mac:

  go build name_of_binary.go

Windows:

  go build -o name_of_binary.exe name_of_binary.go

Using the binary:

Linux or Mac:

  ./calculator 10 + 2
  result: 12

Windows:

  calculator.exe 10 + 2
  result: 12

Cross-Compiling for other OS:

Linux:

  GOOS=linux GOARCH=amd64 go build -o calculator-linux calculator.go

Windows:

  GOOS=windows GOARCH=amd64 go build -o calculator.exe calculator.go

Mac:

  GOOS=darwin GOARCH=amd64 go build -o calculator-mac calculator.go

That's all folks, i hope you liked. :)

Author

Contribute

Contributions are always welcome!

See CONTRIBUTING.md to learn how to get started.