diff --git a/p2p/http/example_test.go b/p2p/http/example_test.go index 9ec103409f..7927b7958b 100644 --- a/p2p/http/example_test.go +++ b/p2p/http/example_test.go @@ -134,8 +134,12 @@ func ExampleHost_Serve() { ListenAddrs: []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/50221/http")}, } - go server.Serve() - defer server.Close() + go func() { + err := server.Serve() + if err != nil && err != http.ErrServerClosed { + fmt.Println("Error", err) + } + }() for _, a := range server.Addrs() { s := a.String() @@ -143,6 +147,7 @@ func ExampleHost_Serve() { fmt.Println(addrWithoutSpecificPort) } + server.Close() // Output: /ip4/127.0.0.1/tcp//http }