I have some example code that takes an interface as an input as below.
type RouteGuideServer interface {
...
}
func RegisterRouteGuideServer(s *grpc.Server, srv RouteGuideServer) {
s.RegisterService(&_RouteGuide_serviceDesc, srv)
}
That is all fine and good, but then when implementing this server we have the following code which gives a struct (that implements the interface) to the function as below.
type routeGuideServer struct {
...
}
...
pb.RegisterRouteGuideServer(grpcServer, &routeGuideServer{})
I would expect that an error is thrown when given the wrong type.. why does this work? I feel that this shouldn't work?
I would appriciate any feedback, Thanks!