Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error sign not appearing in Go buffers #2983

Closed
clgroft opened this issue Jan 24, 2020 · 9 comments
Closed

Error sign not appearing in Go buffers #2983

clgroft opened this issue Jan 24, 2020 · 9 comments
Assignees
Labels
bug help wanted w0rp isn't able to work on this currently

Comments

@clgroft
Copy link

clgroft commented Jan 24, 2020

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>>>
@RyanSquared
Copy link
Member

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.

@RyanSquared
Copy link
Member

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

@RyanSquared
Copy link
Member

RyanSquared commented Jan 29, 2020

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.

@ffigiel
Copy link

ffigiel commented Feb 6, 2020

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

@surminus
Copy link

surminus commented Feb 6, 2020

Good tip, thanks @megapctr!

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

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

@clgroft
Copy link
Author

clgroft commented Feb 7, 2020

@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.

@surminus
Copy link

surminus commented Feb 7, 2020

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!

@clgroft
Copy link
Author

clgroft commented Feb 7, 2020

…and it says that right in the :ALEInfo I posted. Thanks @surminus!

@RyanSquared RyanSquared self-assigned this Feb 8, 2020
@w0rp w0rp added bug help wanted w0rp isn't able to work on this currently labels Feb 22, 2020
@hsanson
Copy link
Contributor

hsanson commented Aug 3, 2021

This should be fixed with #3191

@hsanson hsanson closed this as completed Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted w0rp isn't able to work on this currently
Projects
None yet
Development

No branches or pull requests

6 participants