Skip to content

Migrate away from importing github.com/golang/protobuf/{descriptor,proto} in generated code (similar to #1260). #1608

Closed
@marthjod

Description

@marthjod

🐛 Bug Report

Generated gateway code imports github.com/golang/protobuf/{descriptor,proto} which is deprecated according to staticcheck. We're stuck for now on v1.14.5, but afaics there's no fix in newer versions either?

To Reproduce

Run staticcheck on generated gateway code which contains

// rpc/gateway/rpc.pb.gw.go
import (
    "github.com/golang/protobuf/descriptor"
    "github.com/golang/protobuf/proto"
)

Expected behavior

No output.

Actual Behavior

rpc/gateway/rpc.pb.gw.go:16:2: package github.com/golang/protobuf/descriptor is deprecated: See the "google.golang.org/protobuf/reflect/protoreflect" package for how to obtain an EnumDescriptor or MessageDescriptor in order to programatically interact with the protobuf type system.  (SA1019)
rpc/gateway/rpc.pb.gw.go:17:2: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.  (SA1019)
rpc/gateway/rpc.pb.gw.go:32:9: descriptor.ForMessage is deprecated: Not all concrete message types satisfy the Message interface. Use MessageDescriptorProto instead. If possible, the calling code should be rewritten to use protobuf reflection instead. See package "google.golang.org/protobuf/reflect/protoreflect" for details.  (SA1019)

Your Environment

v1.14.5, Ubuntu 20.04.1 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions