观察者网
在JSON中鸟瞰你的proto RPCs。
支持
✅支持google.protobuf.* 类型。
✅支持所有标准的protobuf类型。
安装
这里有两种方法可以安装这个工具。
- 去安装:
go install github.com/AmirSoleimani/protoseye/cmd/...
- 从源代码安装:
git clone git@github.com:AmirSoleimani/protoseye.git
cd protoseye
go install ./cmd/...
protoc-gen-protoseye version
如何使用!
一旦你安装了它,你可以很容易地使用它protoc
find . -name '*.proto' -exec protoc -I=. \
--protoseye_out=./outputs {} \;
例子
例如:输入
message GetBirdRequest {
string id = 1;
}
message GetBirdResponse {
string id = 1;
string name = 2;
int age = 3;
google.protobuf.Timestamp created_at = 4;
}
service BirdService {
rpc GetBird(GetBirdRequest) GetBirdResponse;
}
输出:
// BirdService_bird.GetBirdRequest.json
{
"id": "mystring"
}
// BirdService_bird.GetBirdResponse.json
{
"id": "mystring",
"name": "name",
"age": 13,
"created_at": {
"nanos": 32,
"seconds": 64
}
}
动机
如果你有一个复杂的数据结构,对你的RPC的输入和输出有一个很好的洞察力并不容易(当你有一个巨大的有效载荷时,情况会变得更糟)。这个工具可以帮助你生成一个RPC请求和响应的JSON表示。
目标任务
- 增强测试覆盖率。
- 生成更智能、更具体的随机值。
- 支持自定义和预定义字段值。
- 除了JSON,还支持目录树风格。