From 36ba6a502a4c18effc6207ad7894c8f52edef281 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Mon, 1 Apr 2019 16:15:58 -0400 Subject: [PATCH] internal/lsp: suppress error message when there is no config Change-Id: I04d26ec3967f6515703142a11fc88b115890ab59 Reviewed-on: https://go-review.googlesource.com/c/tools/+/170185 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Ian Cottrell --- internal/lsp/server.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 030666b6..01b252e3 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -632,10 +632,13 @@ func (s *Server) FoldingRanges(context.Context, *protocol.FoldingRangeParams) ([ } func (s *Server) processConfig(view *cache.View, config interface{}) error { - //TODO: we should probably store and process more of the config + // TODO: We should probably store and process more of the config. + if config == nil { + return nil // ignore error if you don't have a config + } c, ok := config.(map[string]interface{}) if !ok { - return fmt.Errorf("Invalid config gopls type %T", config) + return fmt.Errorf("invalid config gopls type %T", config) } env := c["env"] if env == nil { @@ -643,7 +646,7 @@ func (s *Server) processConfig(view *cache.View, config interface{}) error { } menv, ok := env.(map[string]interface{}) if !ok { - return fmt.Errorf("Invalid config gopls.env type %T", env) + return fmt.Errorf("invalid config gopls.env type %T", env) } for k, v := range menv { view.Config.Env = applyEnv(view.Config.Env, k, v)