Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Make sure gopath and path configured correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
nanliu committed Jun 28, 2016
1 parent a1854e0 commit 87c3564
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ _go_get() {
type -p "${_util}" > /dev/null || go get "${_url}" && _debug "go get ${_util} ${_url}"
}

_path_prepend() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1${PATH:+":$PATH"}"
fi
}

_go_path() {
[[ ! -z $GOPATH ]] || _error "Error \$GOPATH unset"

# NOTE: handles colon separated gopath
go_bin_path=${GOPATH//://bin:}/bin

_path_prepend "${go_bin_path}"

_debug "GOPATH: ${GOPATH}"
_debug "PATH: ${PATH}"
}

_goimports() {
_go_get golang.org/x/tools/cmd/goimports
test -z "$(goimports -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") | tee /dev/stderr)"
Expand Down
1 change: 1 addition & 0 deletions scripts/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ install_go_dep() {
restore_go_dep() {
local _dep=${_dep:=$(_detect_dep)}
_info "restoring dependency with ${_dep}"
_go_path
case $_dep in
godep)
(cd "${__proj_dir}" && godep restore)
Expand Down

0 comments on commit 87c3564

Please sign in to comment.