mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-09 22:14:44 +08:00
Support $GO111MODULE with Go tooling
Allows the user to override $GO111MODULE environment variable through ale options. This gives control over the default behavior of Go module resolution. Golang documentation: https://github.com/golang/go/wiki/Modules#how-to-use-modules Add `ale#Go#EnvString()` function to make it easy to add similar Go environment variables in the future. Use the new `EnvString` function in all available Go tools callbacks & update tests Also add test of linter command callback for `gofmt`
This commit is contained in:
@@ -8,6 +8,7 @@ After:
|
||||
call delete(g:dir . '/.git', 'd')
|
||||
endif
|
||||
|
||||
unlet! b:ale_go_go111module
|
||||
unlet! b:ale_completion_enabled
|
||||
|
||||
call ale#assert#TearDownLinterTest()
|
||||
@@ -34,6 +35,12 @@ Execute(should set gopls options):
|
||||
AssertLinter 'gopls',
|
||||
\ ale#Escape('gopls') . ' --mode stdio --trace'
|
||||
|
||||
Execute(should support go environment variables):
|
||||
let b:ale_go_go111module = 'off'
|
||||
|
||||
AssertLinter 'gopls',
|
||||
\ ale#Env('GO111MODULE', 'off') . ale#Escape('gopls') . ' --mode stdio'
|
||||
|
||||
Execute(Should return directory for 'go.mod' if found in parent directory):
|
||||
call ale#test#SetFilename('../go_files/test.go')
|
||||
|
||||
@@ -44,3 +51,20 @@ Execute(Should return nearest directory with '.git' if found in parent directory
|
||||
call mkdir(g:dir . '/.git')
|
||||
|
||||
AssertLSPProject g:dir
|
||||
|
||||
Execute(Should ignore 'go.mod' and return '.git' dir if modules off):
|
||||
call ale#test#SetFilename('../go_files/test.go')
|
||||
|
||||
let b:ale_go_go111module = 'off'
|
||||
let b:parent_dir = ale#path#Simplify(g:dir . '/..')
|
||||
let b:git_dir = b:parent_dir . '/.git'
|
||||
|
||||
if !isdirectory(b:git_dir)
|
||||
call mkdir(b:git_dir)
|
||||
endif
|
||||
|
||||
AssertLSPProject b:parent_dir
|
||||
|
||||
call delete(b:git_dir, 'd')
|
||||
unlet! b:parent_dir
|
||||
unlet! b:git_dir
|
||||
|
||||
Reference in New Issue
Block a user