Build a Calculator
Setup
Create a folder named calculator in your go-academy directory. We don't need to create additional packages for this project. We can keep everything in the package main.
HTTP Server
We are going to use Go's built-in package net/http to create a calculator server. The server should have 4 API GET endpoints, each endpoint serves a different arithmetic operation.
For example,
api/adddoes additionapi/subdoes subtractionapi/muldoes multiplicationapi/divdoes division
Each endpoint takes in 2 query parameters, left operand and right operand, denoted by lop and rop.
Project Calculator
Source
Last updated