###报错###
```
can't find service RpcServer.Message
```
####代码:
```
package ws
import (
"fmt"
"log"
"net"
"net/http"
"net/rpc"
"os"
)
type RpcServer struct{}
type msgJson struct {
Msg string `json:"msg"`
To []string `json:"to"`
Type string `json:"type"`
}
type response struct {
code int
msg string
}
func RpcServerStart(RPCPort string) {
rpc.Register(new(RpcServer))
rpc.HandleHTTP()
fmt.Println("rpc port :", RPCPort)
lis, err := net.Listen("tcp", RPCPort)
if err != nil {
log.Fatalln("RPC listen error: ", err)
}
fmt.Fprintf(os.Stdout, "%s", "start rpc connection\n")
http.Serve(lis, nil)
}
func (this *RpcServer) Message(req msgJson, res *response) {
fmt.Println("req:\n")
fmt.Println(req)
fmt.Println("end\n")
}
func RpcClient(msg msgJson, ip string) {
var res response
conn, err := rpc.DialHTTP("tcp", ip)
if err != nil {
log.Fatalln("dailing error: ", err)
}
err = conn.Call("RpcServer.Message", msg, &res)
if err != nil {
log.Fatalln("cell error: ", err)
}
}
```
### 大佬这是什么问题呀?为啥找不到呢? ###
有疑问加站长微信联系(非本文作者)