0

I am new to gRPC. I am implementing grpc transcoding in which I am facing an error regarding (missing method ProtoReflect). This me because of "google.golang.org/protobuf/proto" and "github.com/golang/protobuf/proto".

The .pb.go file contains proto package

// Code generated by protoc-gen-go. DO NOT EDIT.
// source: routing/routing.proto

package routing

import (
    fmt "fmt"
    proto "github.com/golang/protobuf/proto"
    _ "google.golang.org/genproto/googleapis/api/annotations"
    math "math"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package

"github.com/golang/protobuf/proto"

Whereas, .pb.gw.go contains "google.golang.org/protobuf/proto"


/*
Package routing is a reverse proxy.

It translates gRPC into RESTful JSON APIs.
*/
package routing

import (
    "context"
    "io"
    "net/http"

    "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
    "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
    "google.golang.org/grpc"
    "google.golang.org/grpc/codes"
    "google.golang.org/grpc/grpclog"
    "google.golang.org/grpc/metadata"
    "google.golang.org/grpc/status"
    "google.golang.org/protobuf/proto"
)

// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join

Go version: 1.18

How can I resolve this?

  • 1
    Show us [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – PRATHEESH PC Jul 12 '23 at 12:11
  • 1
    I suspect if you `protoc-gen-go --version`, you'll get a (github.com/golang/protobuf) deprecated first [version](https://pkg.go.dev/github.com/golang/protobuf/protoc-gen-go?tab=versions) rather than a (google.golang.org/protobuf) second|current [version](https://pkg.go.dev/google.golang.org/protobuf?tab=versions). You can upgrade using `go install google.golang.org/protobuf/cmd/protoc-gen-go@latest`. See the gRPC [Quick start for Go](https://grpc.io/docs/languages/go/quickstart/) too – DazWilkin Jul 12 '23 at 15:46
  • Thank you @DazWilkin, I have upgraded the version but still facing the same problem. – Sahildeep Kaur Jul 13 '23 at 03:01
  • The issue is resolved. The path was incorrect. https://gist.github.com/dzungtran/c0bc39f57db02c564596096ba3c4872a – Sahildeep Kaur Jul 13 '23 at 03:44

0 Answers0