#! /bin/bash ss=simpleserve function main() { init server local name="$(gitname)" pack "$name" } function init() { set -e cd "$(dirname "$BASH_SOURCE")" } function server() { pushd "$GOPATH/src/local/$ss" local f="$(gobuild)" popd mv "$f" "./$ss" } function gobuild() { GOOS=linux CGO_ENABLED=0 go build -o /tmp/${PWD##*/} -a -installsuffix cgo >&2 echo "/tmp/${PWD##*/}" } function gitname() { local name="$(git describe --tags)" if [ -z "$name" ]; then name="$(git rev-parse --abbrev-ref HEAD)" fi echo "$name" } function pack() { tar -czf "$1.tar" "$ss" "public" echo "$1.tar" } if [ "$0" == "${BASH_SOURCE[0]}" ]; then main "$@" fi