Last active
February 9, 2018 00:56
-
-
Save ParthDesai/ca422ce77052ed1b646876f6c70a555a 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 main | |
import ( | |
"shared" //Path to the package contains shared struct | |
) | |
// Every method that we want to export must have | |
// (1) the method has two arguments, both exported (or builtin) types | |
// (2) the method's second argument is a pointer | |
// (3) the method has return type error | |
type Arith int | |
func (t *Arith) Multiply(args *shared.Args, reply *int) error { | |
*reply = args.A * args.B | |
return nil | |
} | |
func (t *Arith) Divide(args *shared.Args, quo *shared.Quotient) error { | |
if args.B == 0 { | |
return errors.New("divide by zero") | |
} | |
quo.Quo = args.A / args.B | |
quo.Rem = args.A % args.B | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment