bufconn in-memory gRPC testing
bufconn is a Go gRPC testing utility that creates an in-memory network connection between a client and a server. In this course, it allows integration tests to exercise generated gRPC clients, server handlers, and status codes without opening a real TCP port.
Minimal example
listener := bufconn.Listen(1024 * 1024)
server := grpc.NewServer()
go server.Serve(listener)
conn, err := grpc.NewClient(
"passthrough:///bufnet",
grpc.WithContextDialer(dialer),
)Learn this concept
Lesson 7.12 · Protobuf contracts in GoUsed in exercises
Exercise 7.13 · gRPC order servicePrerequisite conceptsgRPC