# panic：解析目标 "localhost:50051" 失败：解析错误：缺少 scheme

- **ID:** `go/grpc-failed-to-parse-address`
- **领域:** go
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

较新版本的 gRPC 中 grpc.NewClient 要求目标带 scheme 前缀（如 dns:///、passthrough:///）；裸 host:port 会被拒绝。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| google.golang.org/grpc 1.63+ | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Use a valid scheme:
conn, err := grpc.NewClient("dns:///localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
// or for a literal address:
conn, err := grpc.NewClient("passthrough:///localhost:50051", ...)
   ```
2. **** (85% 成功率)
   ```
   Register a custom resolver if you need a non-DNS scheme:
resolver.Register(&myResolverBuilder{})
   ```

## 无效尝试

- **** — grpc.Dial is deprecated but still works; however it hides the migration and will be removed. (60% 失败率)
- **** — gRPC does not understand http://; it expects a gRPC resolver scheme. (85% 失败率)
