Skip to content

Commit

Permalink
Fix get_tools command
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Dec 6, 2018
1 parent ad0bf5b commit b6e4d6c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
GOTOOLS = \
github.com/golang/dep/cmd/dep \
gopkg.in/alecthomas/gometalinter.v2 \
github.com/mitchellh/gox \
github.com/golang/dep/cmd/dep \
github.com/alecthomas/gometalinter \
github.com/gogo/protobuf/protoc-gen-gogo \
github.com/gobuffalo/packr/packr
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
BUILD_TAGS?=minter
Expand Down Expand Up @@ -30,8 +32,7 @@ check_tools:

get_tools:
@echo "--> Installing tools"
go get -u -v $(GOTOOLS)
@gometalinter.v2 --install
./scripts/get_tools.sh

update_tools:
@echo "--> Updating tools"
Expand Down
43 changes: 43 additions & 0 deletions scripts/get_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -e

## check if GOPATH is set
if [ -z ${GOPATH+x} ]; then
echo "please set GOPATH (https://github.com/golang/go/wiki/SettingGOPATH)"
exit 1
fi

mkdir -p "$GOPATH/src/github.com"
cd "$GOPATH/src/github.com" || exit 1

installFromGithub() {
repo=$1
commit=$2
# optional
subdir=$3
echo "--> Installing $repo ($commit)..."
if [ ! -d "$repo" ]; then
mkdir -p "$repo"
git clone "https://github.com/$repo.git" "$repo"
fi
if [ ! -z ${subdir+x} ] && [ ! -d "$repo/$subdir" ]; then
echo "ERROR: no such directory $repo/$subdir"
exit 1
fi
pushd "$repo" && \
git fetch origin && \
git checkout -q "$commit" && \
if [ ! -z ${subdir+x} ]; then cd "$subdir" || exit 1; fi && \
go install && \
if [ ! -z ${subdir+x} ]; then cd - || exit 1; fi && \
popd || exit 1
echo "--> Done"
echo ""
}

installFromGithub mitchellh/gox 51ed453898ca5579fea9ad1f08dff6b121d9f2e8
installFromGithub golang/dep 22125cfaa6ddc71e145b1535d4b7ee9744fefff2 cmd/dep
installFromGithub alecthomas/gometalinter 17a7ffa42374937bfecabfb8d2efbd4db0c26741
installFromGithub gogo/protobuf 61dbc136cf5d2f08d68a011382652244990a53a9 protoc-gen-gogo
installFromGithub square/certstrap e27060a3643e814151e65b9807b6b06d169580a7
installFromGithub gobuffalo/packr 0bf68f085c6ef75e9f2403052b9e79ddd42a660e

0 comments on commit b6e4d6c

Please sign in to comment.