# rpc错误：代码=未实现 描述=方法 /helloworld.Greeter/SayHello 未实现

- **ID:** `go/grpc-unimplemented-method-not-found`
- **领域:** go
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器没有为请求的RPC方法注册处理程序，通常是由于protobuf定义与服务器实现不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## 解决方案

1. **Ensure the server registers the exact method from the protobuf service definition.** (95% 成功率)
   ```
   type server struct {
    pb.UnimplementedGreeterServer
}
func (s *server) SayHello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloReply, error) {
    return &pb.HelloReply{Message: "Hello " + req.Name}, nil
}
// Then register: pb.RegisterGreeterServer(grpcServer, &server{})
   ```
2. **Regenerate protobuf code and rebuild both client and server.** (90% 成功率)
   ```
   protoc --go_out=. --go-grpc_out=. helloworld.proto
go build ./...
   ```

## 无效尝试

- **Restart the server without updating the protobuf definition.** — The server code is missing the method implementation; restarting does not add it. (100% 失败率)
- **Call a different method with similar name hoping it works.** — The client is designed to call a specific method; using another may cause data inconsistency. (95% 失败率)
