#!/bin/bash

set -ex
set -o pipefail

export GOPATH="${HOME}/gocode"
rm -rf ${GOPATH}
mkdir -p ${GOPATH}

# Create `.gopath` file for $PATH detection
touch ${GOPATH}/.gopath

# Install Go-dev related tools
go get -u github.com/nsf/gocode &
go get -u github.com/alecthomas/gometalinter &
go get -u github.com/mailgun/godebug &
go get -u github.com/tools/godep &
go get -u github.com/golang/dep/cmd/dep &
go get -u github.com/shuLhan/go-bindata/... &
wait

# Ensure installed tools can work
${GOPATH}/bin/gometalinter --install --update
vim +:GoInstallBinaries +:qall

# Re-Install hclfmt
go get -u github.com/fatih/hclfmt &

# Normally update non-version dependent tools
go get -u github.com/fiatjaf/jiq/cmd/jiq &

# Install vault related tools
go get -u github.com/hashicorp/vault &
go get -u github.com/Luzifer/vault-patch &
go get -u github.com/Luzifer/vault2env &

# Install own tools
go get -u github.com/Luzifer/password &

# Install packer
go get -u github.com/hashicorp/packer &

wait