ensure go and goenv play well together

pull/1657/head
cornfeedhobo 2020-09-09 19:49:21 -05:00
parent 4365fa8d69
commit a683039a72
No known key found for this signature in database
GPG Key ID: 724357093F994B26
4 changed files with 18 additions and 6 deletions

View File

@ -9,5 +9,5 @@
# gocomplete -install # gocomplete -install
if _command_exists gocomplete && _command_exists go ; then if _command_exists gocomplete && _command_exists go ; then
complete -C "${GOBIN}"/gocomplete go complete -C gocomplete go
fi fi

View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
if _command_exists goenv && [[ -r "$GOENV_ROOT/completions/goenv.bash" ]] ; then
source "$GOENV_ROOT/completions/goenv.bash"
fi

View File

@ -1,9 +1,14 @@
#!/usr/bin/env bash
cite about-plugin cite about-plugin
about-plugin 'go environment variables & path configuration' about-plugin 'go environment variables & path configuration'
command -v go &>/dev/null || return # Load late to ensure goenv runs first, if enabled
# BASH_IT_LOAD_PRIORITY: 275
_command_exists go || return 0
# If using goenv, make sure it can find go
go version &>/dev/null
[[ $? -eq 0 ]] || return 0
function _go_pathmunge_wrap() { function _go_pathmunge_wrap() {
IFS=':' local -a 'a=($1)' IFS=':' local -a 'a=($1)'

View File

@ -8,13 +8,15 @@ about-plugin 'load goenv, if you are using it'
_command_exists goenv || _command_exists goenv ||
[[ -n "$GOENV_ROOT" && -x "$GOENV_ROOT/bin/goenv" ]] || [[ -n "$GOENV_ROOT" && -x "$GOENV_ROOT/bin/goenv" ]] ||
[[ -x "$HOME/.goenv/bin/goenv" ]] || [[ -x "$HOME/.goenv/bin/goenv" ]] ||
return return 0
# Set GOENV_ROOT, if not already set # Set GOENV_ROOT, if not already set
export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}" export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}"
# Add GOENV_ROOT/bin to PATH, if that's where it's installed # Add GOENV_ROOT/bin to PATH, if that's where it's installed
! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]] && pathmunge "$GOENV_ROOT/bin" if ! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]] ; then
pathmunge "$GOENV_ROOT/bin"
fi
# Initialize goenv # Initialize goenv
eval "$(goenv init - bash)" eval "$(goenv init - bash)"