Beispiel #1
0
func (t *Arith) Div(args *msg.ArithRequest, reply *msg.ArithResponse) error {
	if args.GetB() == 0 {
		return errors.New("divide by zero")
	}
	reply.C = proto.Int32(args.GetA() / args.GetB())
	return nil
}
Beispiel #2
0
func (t *Arith) Mul(args *msg.ArithRequest, reply *msg.ArithResponse) error {
	reply.C = proto.Int32(args.GetA() * args.GetB())
	return nil
}
Beispiel #3
0
func (t *Arith) Add(args *msg.ArithRequest, reply *msg.ArithResponse) error {
	reply.C = proto.Int32(args.GetA() + args.GetB())
	log.Printf("Arith.Add(%v, %v): %v", args.GetA(), args.GetB(), reply.GetC())
	return nil
}