> For the complete documentation index, see [llms.txt](https://wskdsgcf.gitbook.io/mastering-go-zh-cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wskdsgcf.gitbook.io/mastering-go-zh-cn/13.0/13.7.md).

# 13.7 远程调用（RPC）

**远程调用（RPC）**&#x662F;一种使用 TCP/IP 的进程间通信的 客户端-服务器机制。 RPC 客户端和 RPC 服务器都使用下面这个命名为 `sharedRPC.go` 的包开发。

```go
package sharedRPC

type MyFloats struct {
    A1, A2 float64
}

type MyInterface interface {
    Multiply(arguments *MyFloats, reply *float64) error
    Power(arguments *MyFloats, reply *float64) error
}
```

`sharedRPC` 包定义了一个名为 `MyInterface` 的接口和一个名为 `MyFloats` 的结构，客户端和服务器都将会使用到。然后，只有 RPC 服务器需要实现这个接口。

之后，您需要执行如下命令安装 `sharedRPC.go` 包：

```
$ mkdir  -p ~/go/src/sharedRPC
$ cp sharedRPC.go ~/go/src/sharedRPC/
$ go install sharedRPC
```
