I am trying to start http and gRPC service at the same time in a Go application. But to my surprise only http server or gRPC server can start up.
func main() {
xxhh.Test1()
xxhh.Test2()
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World !")
})
app.Listen(":3000")
lis, err := net.Listen("tcp", port)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterBookstoreServer(s, &server{})
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to start grpc serve: %v", err)
}
}
And I also find that if I put the http part at first, then http can start up while gRPC can not. the vice versa is also true