Skip to content

Instantly share code, notes, and snippets.

@mbonell
Last active January 26, 2018 18:06
Show Gist options
  • Save mbonell/457600eb3f255eede5d729781fd49e58 to your computer and use it in GitHub Desktop.
Save mbonell/457600eb3f255eede5d729781fd49e58 to your computer and use it in GitHub Desktop.
package service
import (
"errors"
"log"
)
// Calculator represents the service available over the network.
type Calculator int
// Addition stands as an exported method that execute a sum
// operation over the request args.
func (c *Calculator) Addition(rq *Request, rp *Response) error {
log.Printf("Executing addition with args: %+v", rq)
rp.Result = rq.A + rq.B
return nil
}
// Subtraction stands as an exported method that execute a subtraction
// operation over the request args.
func (c *Calculator) Subtraction(rq *Request, rp *Response) error {
log.Printf("Executing subtraction with args: %+v", rq)
rp.Result = 0
return errors.New("unsupported operation")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment