@@ -5,26 +5,38 @@ call ale#Set('go_golangci_lint_options', '')
55call ale#Set (' go_golangci_lint_executable' , ' golangci-lint' )
66call ale#Set (' go_golangci_lint_package' , 1 )
77
8- function ! ale_linters#go#golangci_lint#GetCommand (buffer ) abort
8+ function ! ale_linters#go#golangci_lint#GetExecutable (buffer ) abort
9+ let l: executable = ale#Var (a: buffer , ' go_golangci_lint_executable' )
10+
11+ return l: executable
12+ endfunction
13+
14+ function ! ale_linters#go#golangci_lint#GetCommand (buffer , version ) abort
915 let l: filename = expand (' #' . a: buffer . ' :t' )
1016 let l: options = ale#Var (a: buffer , ' go_golangci_lint_options' )
1117 let l: lint_package = ale#Var (a: buffer , ' go_golangci_lint_package' )
1218
19+ if ale#semver#GTE (a: version , [2 , 0 , 0 ])
20+ let l: options = l: options
21+ \ . ' --output.json.path stdout'
22+ \ . ' --output.text.path stderr'
23+ \ . ' --show-stats=0'
24+ else
25+ let l: options = l: options
26+ \ . ' --out-format=json'
27+ \ . ' --show-stats=0'
28+ endif
1329
1430 if l: lint_package
1531 return ale#go#EnvString (a: buffer )
1632 \ . ' %e run '
1733 \ . l: options
18- \ . ' --out-format=json'
19- \ . ' --show-stats=0'
2034 endif
2135
2236 return ale#go#EnvString (a: buffer )
2337 \ . ' %e run '
2438 \ . ale#Escape (l: filename )
2539 \ . ' ' . l: options
26- \ . ' --out-format=json'
27- \ . ' --show-stats=0'
2840endfunction
2941
3042function ! ale_linters#go#golangci_lint#Handler (buffer , lines ) abort
@@ -58,9 +70,14 @@ endfunction
5870
5971call ale#linter#Define (' go' , {
6072\ ' name' : ' golangci-lint' ,
61- \ ' executable' : { b - > ale#Var ( b , ' go_golangci_lint_executable ' )} ,
73+ \ ' executable' : function ( ' ale_linters#go#golangci_lint#GetExecutable ' ) ,
6274\ ' cwd' : ' %s:h' ,
63- \ ' command' : function (' ale_linters#go#golangci_lint#GetCommand' ),
75+ \ ' command' : {buffer - > ale#semver#RunWithVersionCheck (
76+ \ buffer ,
77+ \ ale_linters#go#golangci_lint#GetExecutable (buffer ),
78+ \ ' %e --version' ,
79+ \ function (' ale_linters#go#golangci_lint#GetCommand' ),
80+ \ )},
6481\ ' callback' : ' ale_linters#go#golangci_lint#Handler' ,
6582\ ' lint_file' : 1 ,
6683\} )
0 commit comments