syntastic icon indicating copy to clipboard operation
syntastic copied to clipboard

Add a new Go linter: gopls

Open jpguerard opened this issue 5 years ago • 5 comments

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.

jpguerard avatar Jun 26 '19 17:06 jpguerard

Your commit doesn't include the actual checker. :smile:

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.

lcd047 avatar Jun 26 '19 18:06 lcd047

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.

jpguerard avatar Jun 26 '19 20:06 jpguerard

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.

lcd047 avatar Jun 27 '19 03:06 lcd047

  • 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 avatar Jun 27 '19 21:06 jpguerard

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

jpguerard avatar Jul 03 '19 20:07 jpguerard