Last active
January 26, 2018 18:06
-
-
Save mbonell/457600eb3f255eede5d729781fd49e58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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