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

Improve caching for go env calls #1320

Merged
merged 1 commit into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autoload/go/impl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ endif

function! s:root_dirs() abort
let dirs = []
let root = go#util#goroot()
let root = go#util#env("goroot")
if root !=# '' && isdirectory(root)
call add(dirs, root)
endif

let paths = map(split(go#util#gopath(), go#util#PathListSep()), "substitute(v:val, '\\\\', '/', 'g')")
let paths = map(split(go#util#env("gopath"), go#util#PathListSep()), "substitute(v:val, '\\\\', '/', 'g')")
if go#util#ShellError()
return []
endif
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/package.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function! go#package#Paths() abort

if !exists("s:goroot")
if executable('go')
let s:goroot = go#util#goroot()
let s:goroot = go#util#env("goroot")
if go#util#ShellError() != 0
echomsg '''go env GOROOT'' failed'
endif
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/path.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endfunction
function! go#path#Default() abort
if $GOPATH == ""
" use default GOPATH via go env
return go#util#gopath()
return go#util#env("gopath")
endif

return $GOPATH
Expand Down
10 changes: 9 additions & 1 deletion autoload/go/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,32 @@ function! go#util#env(key) abort
return l:var
endfunction

" goarch returns 'go env GOARCH'. This is an internal function and shouldn't
" be used. Instead use 'go#util#env("goarch")'
function! go#util#goarch() abort
return substitute(go#util#System('go env GOARCH'), '\n', '', 'g')
endfunction

" goos returns 'go env GOOS'. This is an internal function and shouldn't
" be used. Instead use 'go#util#env("goos")'
function! go#util#goos() abort
return substitute(go#util#System('go env GOOS'), '\n', '', 'g')
endfunction

" goroot returns 'go env GOROOT'. This is an internal function and shouldn't
" be used. Instead use 'go#util#env("goroot")'
function! go#util#goroot() abort
return substitute(go#util#System('go env GOROOT'), '\n', '', 'g')
endfunction

" gopath returns 'go env GOPATH'. This is an internal function and shouldn't
" be used. Instead use 'go#util#env("gopath")'
function! go#util#gopath() abort
return substitute(go#util#System('go env GOPATH'), '\n', '', 'g')
endfunction

function! go#util#osarch() abort
return go#util#goos() . '_' . go#util#goarch()
return go#util#env("goos") . '_' . go#util#env("goarch")
endfunction

" System runs a shell command. If possible, it will temporary set
Expand Down