You can create a simple calculator in Go using the built-in fmt and strconv packages. Here's a basic implementation:
main.go833 chars41 linesThis implementation takes two floats and an operation as inputs, and uses a switch statement to perform the requested operation. Note that the division operation checks for a denominator of zero and prints an error message if necessary.
You can run this program by saving it to a file (e.g. calculator.go) and typing go run calculator.go in your terminal.
gistlibby LogSnag