Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…

#!/bin/sh | |
echo "Welcome to the Golang project starter" | |
read -p "Enter the GitHub organization or username: " org | |
read -p "Enter the name of your project repo: " repo | |
echo "Setting up directories..." | |
mkdir -p src | |
mkdir -p src/github.com | |
mkdir -p src/github.com/$org | |
mkdir -p src/github.com/$org/$repo | |
mkdir -p src/github.com/$org/$repo/vendor | |
GOPATH=`pwd`; | |
export GOPATH; | |
GOBIN=$GOPATH/bin; | |
export GOBIN; | |
touch setenv.sh | |
echo "export GOPATH=$GOPATH;" > setenv.sh | |
echo "export GOBIN=$GOPATH/bin;" >> setenv.sh | |
chmod +x setenv.sh | |
BUILD_PATH=$GOPATH/src/github.com/$org/$repo | |
cd $BUILD_PATH | |
go get -u github.com/kardianos/govendor | |
$GOBIN/govendor sync | |
echo "Brought in govender and installed dependencies via $GOBIN/govendor sync" | |
echo "Common dependencies..." | |
cd $GOPATH/src/github.com/$org/$repo | |
function getdeps { | |
local depname=$1 | |
local location=$2 | |
while true; do | |
read -p "Do you want $1? (y/n): " yn | |
case $yn in | |
[Yy]* ) $GOBIN/govendor fetch $2; break;; | |
[Nn]* ) break;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
} | |
function customdeps { | |
while true; do | |
read -p "Do you want any custom dependencies? (y/n): " yn | |
case $yn in | |
[Yy]* ) | |
read -p "Whats the url for your custom dep: " depurl | |
$GOBIN/govendor fetch $depurl; | |
continue | |
;; | |
[Nn]* ) break;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
} | |
getdeps "gin-gonic" "github.com/gin-gonic/gin" | |
getdeps "mgo (mongo driver)" "github.com/globalsign/mgo" | |
getdeps "pq (postgres driver)" "github.com/lib/pq" | |
getdeps "mysql (mysql driver)" "github.com/go-sql-driver/mysql" | |
getdeps "gocql (apache cassandra driver)" "github.com/gocql/gocql" | |
getdeps "go-redis (redis driver)" "github.com/go-redis/redis" | |
getdeps "gin-jwt" "github.com/appleboy/gin-jwt" | |
getdeps "jwt-go" "github.com/dgrijalva/jwt-go" | |
getdeps "protoc-gen-go (protocol buffers for gRPC)" "github.com/golang/protobuf/protoc-gen-go" | |
customdeps | |
echo "Run source setenv.sh to set your GOPATH and GOBIN." | |
echo "You can also add this alias to your bash configuration file: \n" | |
echo "alias gp='GOPATH=`pwd`; export GOPATH; GOBIN=\$GOPATH/bin; export GOBIN'" | |
echo "Your project is ready and set up for use." |