Ale: Error sign not appearing in Go buffers

Created on 24 Jan 2020  路  8Comments  路  Source: dense-analysis/ale

Information

VIM version

NVIM v0.4.2
Build type: Release

Operating System: macOS Catalina 10.15.2

What went wrong

When I edit a Go file, ALE runs go vet and finds errors but does not display them in the buffer.

Reproducing the bug

  1. Have ALE installed with no configuration, for example using the following init.vim:
packadd minpac
call minpac#init()
call minpac#add('k-takata/minpac', {'type': 'opt'})
call minpac#add('dense-analysis/ale')

(and with this loaded, run :call minpac#update(), then quit and reopen Neovim for good measure; I doubt the specific package manager is the issue though)

  1. Create a Go file in Neovim:
package main

func main() {
        var a int
        a = 1
        a := 2
}
  1. The error on line 6 is caught by go vet (which ALE runs), but no flag appears in the gutter.

:ALEInfo

 Current Filetype: go
Available Linters: ['bingo', 'gobuild', 'gofmt', 'golangci-lint', 'golint', 'gometalinter', 'gopls', 'gosimple', 'gotype', 'govet', 'golangserver', 'staticcheck']
   Linter Aliases:
'gobuild' -> ['go build']
'govet' -> ['go vet']
  Enabled Linters: ['gofmt', 'golint', 'govet']
 Suggested Fixers: 
  'gofmt' - Fix Go files with go fmt.
  'goimports' - Fix Go files imports with goimports.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_go_go_executable = 'go'
let g:ale_go_golangci_lint_executable = 'golangci-lint'
let g:ale_go_golangci_lint_options = '--enable-all'
let g:ale_go_golangci_lint_package = 0
let g:ale_go_golint_executable = 'golint'
let g:ale_go_golint_options = ''
let g:ale_go_govet_options = ''
let g:ale_go_langserver_executable = 'go-langserver'
let g:ale_go_langserver_options = ''
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) gofmt
(finished - exit code 0) ['/bin/zsh', '-c', '''gofmt'' -e ''/var/folders/2l/cx2bfrg57m7grwltpclg65qc0000gq/T/nvimHu6ccx/1/hello.go''']

<<<NO OUTPUT RETURNED>>>

(executable check - success) golint
(finished - exit code 0) ['/bin/zsh', '-c', '''golint'' ''/var/folders/2l/cx2bfrg57m7grwltpclg65qc0000gq/T/nvimHu6ccx/2/hello.go''']

<<<NO OUTPUT RETURNED>>>

(executable check - success) go
(finished - exit code 2) ['/bin/zsh', '-c', 'cd ''/Users/CIA223/workspaces/go/src/hello'' &&  go vet  .']

<<<OUTPUT STARTS>>>
# hello
vet: ./hello.go:6:4: no new variables on left side of :=
<<<OUTPUT ENDS>>>

(finished - exit code 0) ['/bin/zsh', '-c', '''gofmt'' -e ''/var/folders/2l/cx2bfrg57m7grwltpclg65qc0000gq/T/nvimHu6ccx/4/hello.go''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 0) ['/bin/zsh', '-c', '''golint'' ''/var/folders/2l/cx2bfrg57m7grwltpclg65qc0000gq/T/nvimHu6ccx/5/hello.go''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 2) ['/bin/zsh', '-c', 'cd ''/Users/CIA223/workspaces/go/src/hello'' &&  go vet  .']

<<<OUTPUT STARTS>>>
# hello
vet: ./hello.go:6:4: no new variables on left side of :=
<<<OUTPUT ENDS>>>

(finished - exit code 0) ['/bin/zsh', '-c', '''gofmt'' -e ''/var/folders/2l/cx2bfrg57m7grwltpclg65qc0000gq/T/nvimHu6ccx/6/hello.go''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 0) ['/bin/zsh', '-c', '''golint'' ''/var/folders/2l/cx2bfrg57m7grwltpclg65qc0000gq/T/nvimHu6ccx/7/hello.go''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 2) ['/bin/zsh', '-c', 'cd ''/Users/CIA223/workspaces/go/src/hello'' &&  go vet  .']

<<<OUTPUT STARTS>>>
# hello
vet: ./hello.go:6:4: no new variables on left side of :=
<<<OUTPUT ENDS>>>
bug help wanted

Most helpful comment

Good tip, thanks @megapctr!

For anyone else who wants to do this add the following to ~/.vimrc:

let g:ale_linters = {
\   'go': ['gobuild'],
\}

All 8 comments

I believe the issue is here: https://github.com/dense-analysis/ale/blob/master/autoload/ale/handlers/go.vim#L11

The pattern for this can be tested at https://regex101.com with the example line:

vet: ./hello.go:6:4: no new variables on left side of :=

The first match designed to match the "vet: " portion of it is not valid because it'll only match one character. This should have been caught by tests. I'll need to look into it some more.

I have published a fixed pattern on regex101 here: https://regex101.com/r/FgpyRP/1

related: #2761, #2776

With respects to doesnotcommit, i'll probably rework that PR into something that's more permissive in case other Go mechanisms have something similar down the line, and will be adding some tests for them.

I had the same issue, switching to gobuild linter helped. go vet linter has been broken for a while now

Good tip, thanks @megapctr!

For anyone else who wants to do this add the following to ~/.vimrc:

let g:ale_linters = {
\   'go': ['gobuild'],
\}

@megapctr, @surminus, do you have more context on gobuild? I see a code archive on Google that doesn't seem to have install instructions and a web-based compiler that also almost certainly isn't what you meant.

If you check the ALEInfo as posted above, it seems to be an alias for the plain go build command:

 Current Filetype: go
Available Linters: ['bingo', 'gobuild', 'gofmt', 'golangci-lint', 'golint', 'gometalinter', 'gopls', 'gosimple', 'gotype', 'govet', 'golangserver', 'staticcheck']
   Linter Aliases:
'gobuild' -> ['go build']
...

So should work out the box!

鈥nd it says that right in the :ALEInfo I posted. Thanks @surminus!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kronos29296 picture kronos29296  路  4Comments

sodiumjoe picture sodiumjoe  路  4Comments

amerov picture amerov  路  4Comments

trevordmiller picture trevordmiller  路  4Comments

catbaron0 picture catbaron0  路  3Comments