All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Horacio Sanson https://github.com/hsanson
2 " Description: Functions for integrating with Go tools
4 " Find the nearest dir listed in GOPATH and assume it the root of the go
6 function! ale#go#FindProjectRoot(buffer) abort
7 let l:sep = has('win32') ? ';' : ':'
9 let l:filename = ale#path#Simplify(expand('#' . a:buffer . ':p'))
11 for l:name in split($GOPATH, l:sep)
12 let l:path_dir = ale#path#Simplify(l:name)
14 " Use the directory from GOPATH if the current filename starts with it.
15 if l:filename[: len(l:path_dir) - 1] is? l:path_dir
20 let l:default_go_path = ale#path#Simplify(expand('~/go'))
22 if isdirectory(l:default_go_path)
23 return l:default_go_path
30 call ale#Set('go_go111module', '')
32 " Return a string setting Go-specific environment variables
33 function! ale#go#EnvString(buffer) abort
36 " GO111MODULE - turn go modules behavior on/off
37 let l:go111module = ale#Var(a:buffer, 'go_go111module')
39 if !empty(l:go111module)
40 let l:env = ale#Env('GO111MODULE', l:go111module) . l:env
46 function! ale#go#GetGoPathExecutable(suffix) abort
47 let l:prefix = $GOPATH
50 let l:prefix = $GOPATH
52 let l:prefix = $USERPROFILE . '/go'
54 let l:prefix = $HOME . '/go'
57 return ale#path#Simplify(l:prefix . '/' . a:suffix)