Fix #2668 - Set g:ale_go_go111module
This commit is contained in:
parent
3ae01ba249
commit
dd1e1025b8
16 changed files with 67 additions and 17 deletions
|
@ -29,6 +29,7 @@ g:ale_go_go_executable *g:ale_go_go_options*
|
||||||
The executable that will be run for the `gobuild` and `govet` linters, and
|
The executable that will be run for the `gobuild` and `govet` linters, and
|
||||||
the `gomod` fixer.
|
the `gomod` fixer.
|
||||||
|
|
||||||
|
|
||||||
g:ale_go_go111module *g:ale_go_go111module*
|
g:ale_go_go111module *g:ale_go_go111module*
|
||||||
*b:ale_go_go111module*
|
*b:ale_go_go111module*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
|
|
|
@ -142,6 +142,9 @@ let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0)
|
||||||
" Enable automatic detection of pipenv for Python linters.
|
" Enable automatic detection of pipenv for Python linters.
|
||||||
let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0)
|
let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0)
|
||||||
|
|
||||||
|
" This variable can be overridden to set the GO111MODULE environment variable.
|
||||||
|
let g:ale_go_go111module = get(g:, 'ale_go_go111module', '')
|
||||||
|
|
||||||
if g:ale_set_balloons
|
if g:ale_set_balloons
|
||||||
call ale#balloon#Enable()
|
call ale#balloon#Enable()
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'bingo')
|
call ale#assert#SetUpLinterTest('go', 'bingo')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'gofmt')
|
call ale#assert#SetUpLinterTest('go', 'gofmt')
|
||||||
call ale#test#SetFilename('../go_files/testfile2.go')
|
call ale#test#SetFilename('../go_files/testfile2.go')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The default gofmt command should be correct):
|
Execute(The default gofmt command should be correct):
|
||||||
|
@ -15,5 +21,3 @@ Execute(The gofmt command should support Go environment variables):
|
||||||
AssertLinter 'gofmt',
|
AssertLinter 'gofmt',
|
||||||
\ ale#Env('GO111MODULE', 'on')
|
\ ale#Env('GO111MODULE', 'on')
|
||||||
\ . ale#Escape('gofmt') . ' -e %t'
|
\ . ale#Escape('gofmt') . ' -e %t'
|
||||||
|
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'golangci_lint')
|
call ale#assert#SetUpLinterTest('go', 'golangci_lint')
|
||||||
call ale#test#SetFilename('test.go')
|
call ale#test#SetFilename('test.go')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The golangci-lint defaults should be correct):
|
Execute(The golangci-lint defaults should be correct):
|
||||||
|
@ -40,8 +46,6 @@ Execute(The golangci-lint callback should support environment variables):
|
||||||
\ . ' run ' . ale#Escape(expand('%' . ':t'))
|
\ . ' run ' . ale#Escape(expand('%' . ':t'))
|
||||||
\ . ' --enable-all'
|
\ . ' --enable-all'
|
||||||
|
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
||||||
Execute(The golangci-lint `lint_package` option should use the correct command):
|
Execute(The golangci-lint `lint_package` option should use the correct command):
|
||||||
let b:ale_go_golangci_lint_package = 1
|
let b:ale_go_golangci_lint_package = 1
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Before:
|
Before:
|
||||||
Save $GOPATH
|
Save $GOPATH
|
||||||
Save g:ale_completion_enabled
|
Save g:ale_completion_enabled
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
let g:ale_completion_enabled = 0
|
let g:ale_completion_enabled = 0
|
||||||
let g:sep = has('win32') ? ';' : ':'
|
let g:sep = has('win32') ? ';' : ':'
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'golint')
|
call ale#assert#SetUpLinterTest('go', 'golint')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The default golint command should be correct):
|
Execute(The default golint command should be correct):
|
||||||
|
@ -22,5 +28,3 @@ Execute(The golint command should support Go environment variables):
|
||||||
|
|
||||||
AssertLinter 'golint',
|
AssertLinter 'golint',
|
||||||
\ ale#Env('GO111MODULE', 'on') . ale#Escape('golint') . ' %t'
|
\ ale#Env('GO111MODULE', 'on') . ale#Escape('golint') . ' %t'
|
||||||
|
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'gometalinter')
|
call ale#assert#SetUpLinterTest('go', 'gometalinter')
|
||||||
call ale#test#SetFilename('test.go')
|
call ale#test#SetFilename('test.go')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The gometalinter defaults should be correct):
|
Execute(The gometalinter defaults should be correct):
|
||||||
|
@ -32,13 +38,13 @@ Execute(The gometalinter callback should use configured options):
|
||||||
|
|
||||||
Execute(The gometalinter should use configured environment variables):
|
Execute(The gometalinter should use configured environment variables):
|
||||||
let b:ale_go_go111module = 'off'
|
let b:ale_go_go111module = 'off'
|
||||||
|
|
||||||
AssertLinter 'gometalinter',
|
AssertLinter 'gometalinter',
|
||||||
\ ale#path#CdString(expand('%:p:h'))
|
\ ale#path#CdString(expand('%:p:h'))
|
||||||
\ . ale#Env('GO111MODULE', 'off')
|
\ . ale#Env('GO111MODULE', 'off')
|
||||||
\ . ale#Escape('gometalinter')
|
\ . ale#Escape('gometalinter')
|
||||||
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
|
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
|
||||||
\ . ' .'
|
\ . ' .'
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
||||||
Execute(The gometalinter `lint_package` option should use the correct command):
|
Execute(The gometalinter `lint_package` option should use the correct command):
|
||||||
let b:ale_go_gometalinter_lint_package = 1
|
let b:ale_go_gometalinter_lint_package = 1
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'gopls')
|
call ale#assert#SetUpLinterTest('go', 'gopls')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
|
||||||
|
|
||||||
if isdirectory(g:dir . '/.git')
|
if isdirectory(g:dir . '/.git')
|
||||||
call delete(g:dir . '/.git', 'd')
|
call delete(g:dir . '/.git', 'd')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
unlet! b:ale_go_go111module
|
unlet! b:ale_go_go111module
|
||||||
unlet! b:ale_completion_enabled
|
unlet! b:ale_completion_enabled
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'gosimple')
|
call ale#assert#SetUpLinterTest('go', 'gosimple')
|
||||||
call ale#test#SetFilename('../go_files/testfile2.go')
|
call ale#test#SetFilename('../go_files/testfile2.go')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The default gosimple command should be correct):
|
Execute(The default gosimple command should be correct):
|
||||||
|
@ -15,5 +19,3 @@ Execute(The gosimple command should support Go environment variables):
|
||||||
AssertLinter 'gosimple',
|
AssertLinter 'gosimple',
|
||||||
\ ale#path#CdString(expand('%:p:h')) . ' '
|
\ ale#path#CdString(expand('%:p:h')) . ' '
|
||||||
\ . ale#Env('GO111MODULE', 'on') . 'gosimple .'
|
\ . ale#Env('GO111MODULE', 'on') . 'gosimple .'
|
||||||
|
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'gotype')
|
call ale#assert#SetUpLinterTest('go', 'gotype')
|
||||||
call ale#test#SetFilename('../go_files/testfile2.go')
|
call ale#test#SetFilename('../go_files/testfile2.go')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The default gotype command should be correct):
|
Execute(The default gotype command should be correct):
|
||||||
|
@ -21,5 +25,3 @@ Execute(The gotype callback should support Go environment variables):
|
||||||
\ ale#path#CdString(expand('%:p:h')) . ' '
|
\ ale#path#CdString(expand('%:p:h')) . ' '
|
||||||
\ . ale#Env('GO111MODULE', 'on')
|
\ . ale#Env('GO111MODULE', 'on')
|
||||||
\ . 'gotype -e .'
|
\ . 'gotype -e .'
|
||||||
|
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
Before:
|
Before:
|
||||||
Save g:ale_go_go_executable
|
Save g:ale_go_go_executable
|
||||||
Save g:ale_go_govet_options
|
Save g:ale_go_govet_options
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'govet')
|
call ale#assert#SetUpLinterTest('go', 'govet')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The default command should be correct):
|
Execute(The default command should be correct):
|
||||||
|
@ -12,16 +17,18 @@ Execute(The default command should be correct):
|
||||||
|
|
||||||
Execute(Extra options should be supported):
|
Execute(Extra options should be supported):
|
||||||
let g:ale_go_govet_options = '--foo-bar'
|
let g:ale_go_govet_options = '--foo-bar'
|
||||||
|
|
||||||
AssertLinter 'go', ale#path#CdString(expand('%:p:h')) . ' go vet --foo-bar .'
|
AssertLinter 'go', ale#path#CdString(expand('%:p:h')) . ' go vet --foo-bar .'
|
||||||
|
|
||||||
Execute(The executable should be configurable):
|
Execute(The executable should be configurable):
|
||||||
let g:ale_go_go_executable = 'foobar'
|
let g:ale_go_go_executable = 'foobar'
|
||||||
|
|
||||||
AssertLinter 'foobar', ale#path#CdString(expand('%:p:h')) . ' foobar vet .'
|
AssertLinter 'foobar', ale#path#CdString(expand('%:p:h')) . ' foobar vet .'
|
||||||
|
|
||||||
Execute(Go environment variables should be supported):
|
Execute(Go environment variables should be supported):
|
||||||
let b:ale_go_go111module = 'on'
|
let b:ale_go_go111module = 'on'
|
||||||
|
|
||||||
AssertLinter 'go',
|
AssertLinter 'go',
|
||||||
\ ale#path#CdString(expand('%:p:h')) . ' '
|
\ ale#path#CdString(expand('%:p:h')) . ' '
|
||||||
\ . ale#Env('GO111MODULE', 'on')
|
\ . ale#Env('GO111MODULE', 'on')
|
||||||
\ . 'go vet .'
|
\ . 'go vet .'
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
Before:
|
Before:
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#SetUpLinterTest('go', 'staticcheck')
|
call ale#assert#SetUpLinterTest('go', 'staticcheck')
|
||||||
call ale#test#SetFilename('test.go')
|
call ale#test#SetFilename('test.go')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
Execute(The staticcheck callback should return the right defaults):
|
Execute(The staticcheck callback should return the right defaults):
|
||||||
|
@ -36,8 +40,8 @@ Execute(The staticcheck callback should use the `GO111MODULE` option if set):
|
||||||
|
|
||||||
" Test with lint_package option set
|
" Test with lint_package option set
|
||||||
let b:ale_go_staticcheck_lint_package = 1
|
let b:ale_go_staticcheck_lint_package = 1
|
||||||
|
|
||||||
AssertLinter 'staticcheck',
|
AssertLinter 'staticcheck',
|
||||||
\ ale#path#CdString(expand('%:p:h'))
|
\ ale#path#CdString(expand('%:p:h'))
|
||||||
\ . ale#Env('GO111MODULE', 'off')
|
\ . ale#Env('GO111MODULE', 'off')
|
||||||
\ . 'staticcheck .'
|
\ . 'staticcheck .'
|
||||||
unlet! b:ale_go_go111module
|
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
Before:
|
Before:
|
||||||
Save g:ale_go_gofmt_executable
|
Save g:ale_go_gofmt_executable
|
||||||
Save g:ale_go_gofmt_options
|
Save g:ale_go_gofmt_options
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
" Use an invalid global executable, so we don't match it.
|
" Use an invalid global executable, so we don't match it.
|
||||||
let g:ale_go_gofmt_executable = 'xxxinvalid'
|
let g:ale_go_gofmt_executable = 'xxxinvalid'
|
||||||
let g:ale_go_gofmt_options = ''
|
let g:ale_go_gofmt_options = ''
|
||||||
let g:ale_go_go111module = ''
|
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#test#RestoreDirectory()
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
Execute(The gofmt callback should return the correct default values):
|
Execute(The gofmt callback should return the correct default values):
|
||||||
|
@ -28,6 +30,7 @@ Execute(The gofmt callback should return the correct default values):
|
||||||
|
|
||||||
Execute(The gofmt callback should include custom gofmt options):
|
Execute(The gofmt callback should include custom gofmt options):
|
||||||
let g:ale_go_gofmt_options = "-r '(a) -> a'"
|
let g:ale_go_gofmt_options = "-r '(a) -> a'"
|
||||||
|
|
||||||
call ale#test#SetFilename('../go_files/testfile.go')
|
call ale#test#SetFilename('../go_files/testfile.go')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
|
@ -42,6 +45,7 @@ Execute(The gofmt callback should include custom gofmt options):
|
||||||
|
|
||||||
Execute(The gofmt callback should support Go environment variables):
|
Execute(The gofmt callback should support Go environment variables):
|
||||||
let g:ale_go_go111module = 'off'
|
let g:ale_go_go111module = 'off'
|
||||||
|
|
||||||
call ale#test#SetFilename('../go_files/testfile.go')
|
call ale#test#SetFilename('../go_files/testfile.go')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
Before:
|
Before:
|
||||||
Save g:ale_go_goimports_executable
|
Save g:ale_go_goimports_executable
|
||||||
Save g:ale_go_goimports_options
|
Save g:ale_go_goimports_options
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
" Use an invalid global executable, so we don't match it.
|
" Use an invalid global executable, so we don't match it.
|
||||||
let g:ale_go_goimports_executable = 'xxxinvalid'
|
let g:ale_go_goimports_executable = 'xxxinvalid'
|
||||||
let g:ale_go_goimports_options = ''
|
let g:ale_go_goimports_options = ''
|
||||||
let g:ale_go_go111module = ''
|
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
call ale#test#SetFilename('../go_files/testfile.go')
|
call ale#test#SetFilename('../go_files/testfile.go')
|
||||||
|
@ -13,6 +13,8 @@ Before:
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#test#RestoreDirectory()
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
Execute(The goimports callback should return 0 when the executable isn't executable):
|
Execute(The goimports callback should return 0 when the executable isn't executable):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
Before:
|
Before:
|
||||||
Save g:ale_go_go_executable
|
Save g:ale_go_go_executable
|
||||||
|
Save g:ale_go_go111module
|
||||||
|
|
||||||
" Use an invalid global executable, so we don't match it.
|
" Use an invalid global executable, so we don't match it.
|
||||||
let g:ale_go_go_executable = 'xxxinvalid'
|
let g:ale_go_go_executable = 'xxxinvalid'
|
||||||
|
@ -9,6 +10,8 @@ Before:
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
unlet! b:ale_go_go111module
|
||||||
|
|
||||||
call ale#test#RestoreDirectory()
|
call ale#test#RestoreDirectory()
|
||||||
|
|
||||||
Execute(The gomod callback should return the correct default values):
|
Execute(The gomod callback should return the correct default values):
|
||||||
|
|
Reference in a new issue