<commit_before>CHGO_ROOT=$(cd "$(dirname $BASH_SOURCE[@])"/../.. && pwd)
CHGO_VERSION="0.3.7"
GOES=()

for dir in "$CHGO_ROOT/versions"; do
  [[ -d "$dir" && -n "$(ls -A "$dir")" ]] && GOES+=("$dir"/*)
done
unset dir

mkdir -p $CHGO_ROOT/tmp

function chgo_reset()
{
  [[ -z "$GOROOT" ]] && return

  PATH=":$PATH:"; PATH="${PATH//:$GOROOT\/bin:/:}"
  PATH="${PATH#:}"; PATH="${PATH%:}"
  unset GOROOT
  hash -r
}

function chgo_install()
{
  version=$1
  installdir=$CHGO_ROOT/versions/$version
  logfile=$CHGO_ROOT/tmp/$version-$(date "+%s").log

  mkdir -p $installdir
  platform="$(uname -s | tr '[:upper:]' '[:lower:]')"

  if [ "$(uname -m)" = "x86_64" ]; then arch="amd64"
  else                                  arch="386"
  fi

  (curl -v -f "https://go.googlecode.com/files/go${version}.${platform}-${arch}.tar.gz" | tar zxv --strip-components 1 -C $installdir; exit "${PIPESTATUS[0]}") 2>$logfile >$logfile || \
    {
      rm -rf $installdir<commit_msg>Work-around the change in download naming for darwin<commit_after>CHGO_ROOT=$(cd "$(dirname $BASH_SOURCE[@])"/../.. && pwd)
CHGO_VERSION="0.3.7"
GOES=()

for dir in "$CHGO_ROOT/versions"; do
  [[ -d "$dir" && -n "$(ls -A "$dir")" ]] && GOES+=("$dir"/*)
done
unset dir

mkdir -p $CHGO_ROOT/tmp

function chgo_reset()
{
  [[ -z "$GOROOT" ]] && return

  PATH=":$PATH:"; PATH="${PATH//:$GOROOT\/bin:/:}"
  PATH="${PATH#:}"; PATH="${PATH%:}"
  unset GOROOT
  hash -r
}

function chgo_install()
{
  version=$1
  installdir=$CHGO_ROOT/versions/$version
  logfile=$CHGO_ROOT/tmp/$version-$(date "+%s").log

  mkdir -p $installdir
  platform="$(uname -s | tr '[:upper:]' '[:lower:]')"

  if [ "$(uname -m)" = "x86_64" ]; then arch="amd64"
  else                                  arch="386"
  fi

  download_url="https://go.googlecode.com/files/go${version}.${platform}-${arch}.tar.gz"

  if [[ "$platform" = "darwin" ]]; then
    OSX_VERSION=`sw_vers | grep ProductVersion | cut -f 2 -d ':'  | awk ' { print $1; } '`

    if !(echo $OSX_VERSION | egrep '10\.6|10\.7'); then
      alternate_url="https://go.googlecode.com/files/go${version}.${platform}-${arch}-osx10.6.tar.gz"
    else
      alternate_url="https://go.googlecode.com/files/go${version}.${platform}-${arch}-osx10.8.tar.gz"
    fi
  fi

  ( \
    ( \
      (curl -v -f $download_url) || (curl -v -f $alternate_url) \
    ) | \
    tar zxv --strip-components 1 -C $installdir; exit "${PIPESTATUS[0]}" \
  ) 2>$logfile >$logfile || \
    {
      rm -rf $installdir
{'fraction_non_alphanumeric': 0.23690572119258663, 'fraction_numerical': 0.018533440773569703, 'mean_word_length': 3.097359735973597, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2052073', 'n_tokens_mistral': 1055, 'n_tokens_neox': 987, 'n_words': 190}