code: func NewDialer(h http.Handler) *websocket.Dialer {
  	client, server := net.Pipe()
  	conn := &recorder{server: server}
  
  	// run the runServer in a goroutine, so when the Dial send the request to
  	// the recorder on the connection, it will be parsed as an HTTPRequest and
  	// sent to the Handler function.
  	go conn.runServer(h)
  
  	// use the websocket.NewDialer.Dial with the fake net.recorder to communicate with the recorder
  	// the recorder gets the client which is the client side of the connection
  	return &websocket.Dialer{NetDial: func(network, addr string) (net.Conn, error) { return client, nil }}
  }
docs: // NewDialer creates a wstest recorder to an http.Handler which accepts websocket upgrades.
  // This send an HTTP request to the http.Handler, and wait for the connection upgrade response.
  // it runs the recorder's ServeHTTP function in a goroutine, so recorder can communicate with a
  // client running on the current program flow
  //
  // h is an http.Handler that handles websocket connections.
  // It returns a *websocket.Dial struct, which can then be used to dial to the handler.