Skip to content

Instantly share code, notes, and snippets.

@ParthDesai
Last active February 9, 2018 00:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ParthDesai/ca422ce77052ed1b646876f6c70a555a to your computer and use it in GitHub Desktop.
Save ParthDesai/ca422ce77052ed1b646876f6c70a555a to your computer and use it in GitHub Desktop.
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