报错如下
cannot use &server{} (type *server) as type __.ProductInfoServer in argument to __.RegisterProductInfoServer:
*server does not implement __.ProductInfoServer (missing __.mustEmbedUnimplementedProductInfoServer method)
have mustEmbedUnimplementedProductInfoServer()
want __.mustEmbedUnimplementedProductInfoServer()
这是因为新的版本导致的这个问题,可以通过选项来关闭
protoc --go-grpc_out=require_unimplemented_servers=false:./ *.proto
这个代码的意思是在当前目录为proto文件生成gRPC代码,并且关闭了相应的选项
另外附上在当前目录生成相应代码的语句
protoc -I ./ --go_out=. --go_opt=paths=source_relative --go-grpc_out=require_unimplemented_servers=false:./ *.proto
参考:https://github.com/grpc/grpc-go/blob/master/cmd/protoc-gen-go-grpc/README.md