1 Star 1 Fork 0

rocket049/pipeconn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
pipe-server.go 611 Bytes
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"net/rpc"
"gitee.com/rocket049/pipeconn"
)
import "errors"
type Args struct {
A, B int
}
type Quotient struct {
Quo, Rem int
}
type Arith int
func (t *Arith) Multiply(args *Args, reply *int) error {
*reply = args.A * args.B
return nil
}
func (t *Arith) Divide(args *Args, quo *Quotient) error {
if args.B == 0 {
return errors.New("divide by zero")
}
quo.Rem = args.A % args.B
quo.Quo = args.A / args.B
return nil
}
func main() {
arith := new(Arith)
server := rpc.NewServer()
server.Register(arith)
conn := pipeconn.NewServerPipeConn()
server.ServeConn(conn)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rocket049/pipeconn.git
git@gitee.com:rocket049/pipeconn.git
rocket049
pipeconn
pipeconn
v1.0.0

搜索帮助