type ServerError … func (e ServerError) Error() string { … } var ErrShutdown … type Call … type Client … type ClientCodec … func (client *Client) send(call *Call) { … } func (client *Client) input() { … } func (call *Call) done() { … } // NewClient returns a new [Client] to handle requests to the // set of services at the other end of the connection. // It adds a buffer to the write side of the connection so // the header and payload are sent as a unit. // // The read and write halves of the connection are serialized independently, // so no interlocking is required. However each half may be accessed // concurrently so the implementation of conn should protect against // concurrent reads or concurrent writes. func NewClient(conn io.ReadWriteCloser) *Client { … } // NewClientWithCodec is like [NewClient] but uses the specified // codec to encode requests and decode responses. func NewClientWithCodec(codec ClientCodec) *Client { … } type gobClientCodec … func (c *gobClientCodec) WriteRequest(r *Request, body any) (err error) { … } func (c *gobClientCodec) ReadResponseHeader(r *Response) error { … } func (c *gobClientCodec) ReadResponseBody(body any) error { … } func (c *gobClientCodec) Close() error { … } // DialHTTP connects to an HTTP RPC server at the specified network address // listening on the default HTTP RPC path. func DialHTTP(network, address string) (*Client, error) { … } // DialHTTPPath connects to an HTTP RPC server // at the specified network address and path. func DialHTTPPath(network, address, path string) (*Client, error) { … } // Dial connects to an RPC server at the specified network address. func Dial(network, address string) (*Client, error) { … } // Close calls the underlying codec's Close method. If the connection is already // shutting down, [ErrShutdown] is returned. func (client *Client) Close() error { … } // Go invokes the function asynchronously. It returns the [Call] structure representing // the invocation. The done channel will signal when the call is complete by returning // the same Call object. If done is nil, Go will allocate a new channel. // If non-nil, done must be buffered or Go will deliberately crash. func (client *Client) Go(serviceMethod string, args any, reply any, done chan *Call) *Call { … } // Call invokes the named function, waits for it to complete, and returns its error status. func (client *Client) Call(serviceMethod string, args any, reply any) error { … }