var serverIndex … type streamServer … // NewStreamServer creates a StreamServer using the shared cache. If // withTelemetry is true, each session is instrumented with telemetry that // records RPC statistics. func NewStreamServer(cache *cache.Cache, daemon bool, optionsFunc func(*settings.Options)) jsonrpc2.StreamServer { … } // ServeStream implements the jsonrpc2.StreamServer interface, by handling // incoming streams using a new lsp server. func (s *streamServer) ServeStream(ctx context.Context, conn jsonrpc2.Conn) error { … } type forwarder … // NewForwarder creates a new forwarder (a [jsonrpc2.StreamServer]), // ready to forward connections to the // remote server specified by rawAddr. If provided and rawAddr indicates an // 'automatic' address (starting with 'auto;'), argFunc may be used to start a // remote server for the auto-discovered address. func NewForwarder(rawAddr string, argFunc func(network, address string) []string) (jsonrpc2.StreamServer, error) { … } // QueryServerState returns a JSON-encodable struct describing the state of the named server. func QueryServerState(ctx context.Context, addr string) (any, error) { … } // dialRemote is used for making calls into the gopls daemon. addr should be a // URL, possibly on the synthetic 'auto' network (e.g. tcp://..., unix://..., // or auto://...). func dialRemote(ctx context.Context, addr string) (jsonrpc2.Conn, error) { … } // ExecuteCommand connects to the named server, sends it a // workspace/executeCommand request (with command 'id' and arguments // JSON encoded in 'request'), and populates the result variable. func ExecuteCommand(ctx context.Context, addr string, id string, request, result any) error { … } // ServeStream dials the forwarder remote and binds the remote to serve the LSP // on the incoming stream. func (f *forwarder) ServeStream(ctx context.Context, clientConn jsonrpc2.Conn) error { … } // TODO(rfindley): remove this handshaking in favor of middleware. func (f *forwarder) handshake(ctx context.Context) { … } func ConnectToRemote(ctx context.Context, addr string) (net.Conn, error) { … } // handler intercepts messages to the daemon to enrich them with local // information. func (f *forwarder) handler(handler jsonrpc2.Handler) jsonrpc2.Handler { … } // addGoEnvToInitializeRequest builds a new initialize request in which we set // any environment variables output by `go env` and not already present in the // request. // // It returns an error if r is not an initialize request, or is otherwise // malformed. func addGoEnvToInitializeRequest(ctx context.Context, r jsonrpc2.Request) (jsonrpc2.Request, error) { … } func (f *forwarder) replyWithDebugAddress(outerCtx context.Context, r jsonrpc2.Replier, args command.DebuggingArgs) jsonrpc2.Replier { … } type handshakeRequest … type handshakeResponse … type clientSession … type serverState … const handshakeMethod … const sessionsMethod … func handshaker(session *cache.Session, goplsPath string, logHandshakes bool, handler jsonrpc2.Handler) jsonrpc2.Handler { … } func sendError(ctx context.Context, reply jsonrpc2.Replier, err error) { … } // ParseAddr parses the address of a gopls remote. // TODO(rFindley): further document this syntax, and allow URI-style remote // addresses such as "auto://...". func ParseAddr(listen string) (network string, address string) { … }