2

I need to write a client and a server. Client can send different request types as a GoLang struct, and server should recognize the type, and invoke a corresponding handler function. How would you achieve that? I tried to look into gob package, but I don`t see that it can recognize the type it receives from the stream?

One more quest - is gob package the most efficient way to pass messages between client, and server from the low-latency low-memory utilization perspective?

Mark
  • 423
  • 4
  • 12
  • Possible to use protobuf? with gRPC? – Inian Dec 12 '21 at 17:16
  • 1
    The [net/rpc package](https://pkg.go.dev/net/rpc) is close to what you are looking for. The package uses gob for encoding values on the wire, but the package dispatches on a method name instead of a type. –  Dec 12 '21 at 17:23

0 Answers0