Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Add a new Go linter: gopls #2271

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jpguerard
Copy link

gopls is a new Language Server Protocol implementation for Go. With recent releases, it can also be used as a standalone linter.

This new checker uses gopls to check Go programs.

@lcd047
Copy link
Collaborator

lcd047 commented Jun 26, 2019

Your commit doesn't include the actual checker. 😄

Anyway, please consider adding this to ALE and / or vim-go instead. The go checkers in syntastic are still around only for backwards compatibility, they don't serve any real purpose these days.

@jpguerard
Copy link
Author

From my end, the checker seems to be in the commit.
gopls is already supported by ALE and vim-go.
I'm using syntastic, so this checker was useful to me.

@lcd047
Copy link
Collaborator

lcd047 commented Jun 27, 2019

From my end, the checker seems to be in the commit.

Right, I can see it now too. So either I discovered a race condition in GitHub, or I was just imagining things. I guess I'll spend the rest of my life wondering.

I'm using syntastic, so this checker was useful to me.

Well, the point still stands: go checkers should have been deleted a long time ago, and adding more checkers for me to take care of is not a step in that direction. Also, syntastic is essentially dead these days.

Anyway, about the checker:

  • In IsAvailable() you should probably parse the output rather than check v:shell_error. The latter is known not to work reliably under the cmd.exe shell on Windows, so it should be avoided when possible.
  • You probably want let errorformat = ... '%f:%l:%c-%\d%\+: %m,' .... Backslashes have no special meaning inside single quotes.
  • The exec in CreateAndRegisterChecker() is redundant but not wrong.

@jpguerard
Copy link
Author

  • Parsing the output in IsAvailable would no really be helpful. The first versions of gopls did not understand the commands "version" and "check" (this is the case of the gopls available in Debian). So either "gopls version" fails as it does not understand "go version", and we can't use it. Or it succeed, and can be used.
  • I've correcter errorformat.

@jpguerard
Copy link
Author

I also tested gopls on Windows. It does correctly return an error code if it does not understand the option provided.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants