Archive for alpha

[just.few.tuts] golang ~ get local changes into GOPATH without pushing them upstream

Posted in AbhishekKr, Blogroll, tutorial with tags , , , , on March 4, 2014 by abhishekkr

justfewtuts.blogspot.in [3/Feb/2014]

http://justfewtuts.blogspot.in/2014/02/golang-get-local-changes-into-gopath.html

To get your local Golang repo’s sym-linked at your GOPATH and local changes available…

goenv_link(){
  if [ $# -ne 2 ]; then
    echo "Links up current dir to it's go-get location in GOPATH"
    echo "SYNTAX: goenv_linkme  "
    return 1
  fi
  _REPO_DIR=$1
  _REPO_URL=$2

  _TMP_PWD=$PWD
  cd $_REPO_DIR

  if [ -d "${GOPATH}/src/${_REPO_URL}" ]; then
    echo "$_REPO_URL already exists at GOPATH $GOPATH"
    go get "${_REPO_URL}"
    return 1
  fi
  _REPO_BASEDIR=$(dirname "${GOPATH}/src/${_REPO_URL}")
  if [ ! -d "${_REPO_BASEDIR}" ]; then
    mkdir -p "${_REPO_BASEDIR}/src"
  fi

  ln -sf "${PWD}" "${GOPATH}/src/${_REPO_URL}"
  go get "${_REPO_URL}"

  cd $_TMP_PWD
}

alias goenv_linkme="goenv_link $PWD"

…read full blogpost here

Advertisements