internal/lsp/cmd: suppress EOF errors in serve

When the client closes its connection, we get an EOF, but it's not
really an error. Suppress it so that the gopls binary doesn't exit with
an error.

In principle we should connect this to (lsp.Server).shutdown somehow,
but as far as I know a path for that doesn't exist, and this seems
pretty innocuous to me.

Fixes golang/go#40832.

Change-Id: I9dd83d26bcf5c07e03188d3829e603005d80c8c4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/249417
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go
index 92b9e4e..72e2a8c 100644
--- a/internal/lsp/cmd/serve.go
+++ b/internal/lsp/cmd/serve.go
@@ -6,8 +6,10 @@
 
 import (
 	"context"
+	"errors"
 	"flag"
 	"fmt"
+	"io"
 	"log"
 	"os"
 	"strings"
@@ -105,7 +107,11 @@
 		stream = protocol.LoggingStream(stream, di.LogWriter)
 	}
 	conn := jsonrpc2.NewConn(stream)
-	return ss.ServeStream(ctx, conn)
+	err := ss.ServeStream(ctx, conn)
+	if errors.Is(err, io.EOF) {
+		return nil
+	}
+	return err
 }
 
 // parseAddr parses the -listen flag in to a network, and address.