#!/bin/bash
APPENGINE_VERSION=${1-1.8.4}

# TODO: generate platform and architecture using detection
APPENGINE_SOURCE=http://googleappengine.googlecode.com/files/go_appengine_sdk_linux_amd64-$APPENGINE_VERSION.zip

# don't run the install process if we are in use mode
if [ ! $BASHINATE_USE ]; then
  # if we don't have the latest node version, then install
  log "Checking appengine (go) version $APPENGINE_VERSION installed";
  if [ ! -e $BASHINATE_INSTALL/appengine-go/$APPENGINE_VERSION ]
  then
    log "Installing appengine version $APPENGINE_VERSION"
    hash unzip 2> /dev/null || require packages unzip

    fetchSource $APPENGINE_SOURCE unzip

    mkdir -p $BASHINATE_INSTALL/appengine-go
    mv -f $BASHINATE_SOURCE/go_appengine \
      $BASHINATE_INSTALL/appengine-go/$APPENGINE_VERSION
  fi
fi

linkBinaries appengine-go/$APPENGINE_VERSION go godoc gofmt appcfg.py dev_appserver.py