标签: grpcurl

如何通过 grpcurl 发送时间戳?

我正在使用 GRPC/proto-buffers 在 GoLang 中编写我的第一个 API 端点。我对 Go 还很陌生。以下是我为测试用例编写的文件

package my_package

import (
    "context"
    "testing"

    "github.com/stretchr/testify/require"

    "google.golang.org/protobuf/types/known/structpb"
    "github.com/MyTeam/myproject/cmd/eventstream/setup"
    v1handler "github.com/MyTeam/myproject/internal/handlers/myproject/v1"
    v1interface "github.com/MyTeam/myproject/proto/.gen/go/myteam/myproject/v1"
)

func TestEndpoint(t *testing.T) {
    conf := &setup.Config{}

    // Initialize our API handlers
    myhandler := v1handler.New(&v1handler.Config{})

    t.Run("Success", func(t *testing.T) {
        res, err := myhandler.Endpoint(context.Background(), &v1interface.EndpointRequest{
            A: "S",
            B: &structpb.Struct{
                Fields: map[string]*structpb.Value{
                    "T": &structpb.Value{
                        Kind: &structpb.Value_StringValue{
                            StringValue: "U",
                        },
                    },
                    "V": &structpb.Value{
                        Kind: &structpb.Value_StringValue{
                            StringValue: "W",
                        },
                    },
                },
            },
            C: &timestamppb.Timestamp{Seconds: 1590179525, Nanos: 0},
        })
        require.Nil(t, err)

        // …
Run Code Online (Sandbox Code Playgroud)

go protocol-buffers grpcurl

5
推荐指数
1
解决办法
5966
查看次数

如何安装特定版本的grpcurl?

我试着用

go get github.com/fullstorydev/grpcurl@2108c8f
go install github.com/fullstorydev/grpcurl/cmd/grpcurl
export PATH=$GOPATH/bin:$PATH
Run Code Online (Sandbox Code Playgroud)

在我的 ubuntu 盒子上安装 grpcurl,但在那之后当我做 grpcurl --version 我仍然得到

grpcurl 开发构建

我期待看到

grpcurl 1.16.0
Run Code Online (Sandbox Code Playgroud)

go grpcurl

4
推荐指数
1
解决办法
3056
查看次数

标签 统计

go ×2

grpcurl ×2

protocol-buffers ×1