Skip to content

Commit

Permalink
env cache
Browse files Browse the repository at this point in the history
  • Loading branch information
koron committed Jul 16, 2016
1 parent b1ab840 commit 7b9e4d2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions autoload/go/env.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
let s:cache = {}

function! go#env#cache_clear(key)
call remove(s:cache, a:key)
endfunction

function! go#env#root()
if has_key(s:cache, 'root')
return s:cache['root']
endif
if executable('go')
let root = substitute(system('go env GOROOT'), '\n', '', 'g')
if v:shell_error
Expand All @@ -7,5 +16,6 @@ function! go#env#root()
else
let root = $GOROOT
endif
let s:cache['root'] = root
return root
endfunction

0 comments on commit 7b9e4d2

Please sign in to comment.