internal/jsonrpc2_v2: rename Serve to NewServer and eliminate its error return

Serve had a misleading name and signature: it did not actually block
on serving the connection, and never returned a non-nil error.

Updates golang/go#56281.

Change-Id: Ia6df0ba20066811b0551df3b3267dff2fffd7881
Reviewed-on: https://go-review.googlesource.com/c/tools/+/443678
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
This commit is contained in:
Bryan C. Mills 2022-10-18 12:06:21 -04:00 • committed by Gopher Robot
commit a482202a17

View file

@ -136,10 +136,7 @@ func testConnection(t *testing.T, framer jsonrpc2.Framer) {
if err != nil {
t.Fatal(err)
}
server, err := jsonrpc2.Serve(ctx, listener, binder{framer, nil})
if err != nil {
t.Fatal(err)
}
server := jsonrpc2.NewServer(ctx, listener, binder{framer, nil})
defer func() {
listener.Close()
server.Wait()