Commits

Yoshifumi YAMAGUCHI committed 235adb6 Merge

Merge branch 'release/0.4.0'

Comments (0)

Files changed (6)

 2. Install
 ==========
 
+2.0 pre-requirements
+--------------------
+
+* In advance of using installation scripts, please make sure directories specified by ``$GOENVGOROOT`` and ``$GOENVTARGET`` exist and those permissions are correctly set.
+
+* Make sure ``git`` and ``mercurial`` are installed.
+
 2.1 Fast installation
 ---------------------
 
 or you can run a following command for procedure all above::
 
    $ export GOENVTARGET=/path/to/install/target
-   $ curl -L https://bitbucket.org/ymotongpoo/goenv/raw/master/shellscripts/fast-install.sh | bash
+   $ curl -L https://bitbucket.org/ymotongpoo/goenv/raw/master/shellscripts/fast-install.sh | zsh
 
+(Author is using zsh)
 
 2.2 Go initial installation
 ---------------------------
 
-If you're fine with installing Go from the source code and goenv at the same time, use initial-install.sh::
-
-   $ curl -L https://bitbucket.org/ymotongpoo/goenv/raw/master/shellscripts/initial-install.sh | bash
-
 You have to set following variables beforehand:
 
 * ``GOENVGOROOT``: Go binary install target. All Go binaries are installed under this directory. 
 * ``GOENVTARGET``: goenv install target. goenv and goenvwrapper.sh are installed here.
 * ``GOENVHOME``: All workspaces created with ``goof`` command are here.
 
+If you're fine with installing Go from the source code and goenv at the same time, use initial-install.sh::
+
+   $ curl -L https://bitbucket.org/ymotongpoo/goenv/raw/master/shellscripts/initial-install.sh | zsh
 
 3. Usage
 ========
    % goof make foo
    (go:foo) % 
 
+``make`` option accepts ``goenv`` command options, so you can create GAE skeleton project with following command for instance::
+
+   % goof make foo -gae
+
+
 ``show`` shows all existing environments. Environment with '*' mark is current environment::
 
    (go:foo) % goof show
    bar *
    foo
 
-To delete unnecessary environment, run ``rmgoenv`` with the environment name::
+To delete unnecessary environment, run ``remove`` with the environment name::
 
    (go:bar) % goof remove foo
    bar *
    * /opt/goenv/go1.0.3
 
 
+4.3 Advanced option
+-------------------
+
+``goof make`` is supporting ``gocode`` and ``godef`` installation which are code auto-completion tool for and code search assistance for go respectively.
+Either of them will be installed under ``GOPATH/bin``::
+
+   % goof make test -gocode -godef
+   % ls $GOPATH/bin/
+   gocode godef
+
 
 5. Contribution
 ===============

bin/goenv.linux-amd64.0.4.0

Binary file added.

bin/goenv.mac-amd64.0.4.0

Binary file added.

shellscripts/goenvwrapper.sh

 
   local envhome
   local args
+  local gocode_flag=false
+  local godef_flag=false
   until [ -z "$1" ]; do
     case "$1" in
       "-go" | "--go")
         args="$args -gae"
         shift
         ;;
+      "-gocode" | "--gocode")
+        gocode_flag=true
+        shift
+        ;;
+      "-godef" | "--godef")
+        godef_flag=true
+        shift
+        ;;
       *)
         envhome="$GOENVHOME/$1"
         shift
     source "$envhome/activate"
   fi
   cd "$envhome"
+  
+  if $gocode_flag; then
+    eval `go get -u github.com/nsf/gocode`
+  fi
+
+  if $godef_flag; then
+    eval `go get code.google.com/p/rog-go/exp/cmd/godef`
+  fi
   return 0
 }
 
   fi
 
   # build and copy directory
+  local repo="$GOENVGOROOT/go"
+  local oldpwd="$PWD"
+  local init=1
   if [ -d "$GOENVGOROOT/$1" ]; then
+    init=0
     echo "[goof] Go version '$1' already exists."
-  else
-    local repo=$GOENVGOROOT/go
-    # initial checkout
+    # if they'd like to upgrade existing version, upgrade it.
+    echo "[goof] Do you want to update branch/tag '$1'? (WARNING: 'y' always rebuild branch) [y/N]: "
+    read answer
+    if [ "$answer" = "y" -o "$answer" = "Y" -o "$answer" = "yes" -o "$answer" = "YES" ]; then
+      echo "[goof] updating '$1'..."
+      eval "cd $repo && hg pull && hg update"
+    else
+      return 0
+    fi
+  fi
+
+  # initial checkout
+  if [ "$init" = 1 ]; then 
     echo "[goof] check repository existence."
     if [ ! -d "$repo" ]; then
       echo "[goof] Go source code initial checkout."
       eval "hg clone -q https://code.google.com/p/go/ --cwd $GOENVGOROOT"
     fi
-    cd $repo
+    cd "$repo"
     if [ ! -d "$repo/logs" ]; then
       mkdir "$repo/logs"
     fi
+  fi
 
-    # check tags
-    if [ "$1" = "tags" ]; then
-      hg tags
-      return 0
-    fi
+  # check tags
+  if [ "$1" = "tags" ]; then
+    hg tags
+    return 0
+  fi
 
-    # build and copy
-    local datetime=`date +"%Y%m%d%H%M%S"`
-    local logfile="$repo/logs/$1-$datetime.log"
-    if eval "hg checkout $1 &> $logfile"; then
-      cd src
-      echo "[goof] building '$1'."
-      if ./all.bash &>> "$logfile"; then
-        cd "$repo"
-        echo "[goof] copying '$1'."
-        if rsync -av --exclude='.hg*' . "$GOENVGOROOT/$1" &>> "$logfile"; then
-          echo "[goof] '$1' is installed in $GOENVGOROOT/$1"
-        fi
-      else
-        echo "see build log file: $logfile"
-        return 1
+  # build and copy
+  local datetime=`date +"%Y%m%d%H%M%S"`
+  local logfile="$repo/logs/$1-$datetime.log"
+  if eval "hg checkout $1 &> $logfile"; then
+    cd src
+    echo "[goof] building '$1'."
+    if ./all.bash &>> "$logfile"; then
+      cd "$repo"
+      echo "[goof] copying '$1'."
+      if rsync -av --exclude='.hg*' . "$GOENVGOROOT/$1" &>> "$logfile"; then
+        echo "[goof] '$1' is installed in $GOENVGOROOT/$1"
       fi
     else
-      echo "check tag name: $1"
+      echo "see build log file: $logfile"
+      cd "$oldpwd"
+      return 1
     fi
+  else
+    echo "check tag name: $1"
   fi
+  cd "$oldpwd"
 }
 
 # goof_go changes current GOROOT in specified version

shellscripts/initial-install.sh

   exit 0
 fi
 
+if [ ! -d "$GOENVGOROOT" ]; then
+  if eval "mkdir $GOENVGOROOT"; then
+    echo "[goenv] please confirm directory permission for GOENVGOROOT"      
+    exit 0
+  fi
+fi
+
+if [ ! -d "$GOENVTARGET" ]; then
+  if eval "mkdir $GOENVTARGET"; then
+    echo "[goenv] please confirm directory permission for GOENVTARGET"      
+    exit 0
+  fi
+fi
+
 cd /tmp
 
 downloader=""
   exit 0
 fi
 
-if $downloader "https://bitbucket.org/ymotongpoo/goenv/raw/master/shellscripts/goenvwrapper.sh"; then
+if eval "$downloader https://bitbucket.org/ymotongpoo/goenv/raw/master/shellscripts/goenvwrapper.sh"; then
   if [ -f "goenvwrapper.sh" ]; then
     source goenvwrapper.sh
   else
 if goof goinstall default; then
   if [ -d "$GOENVGOROOT/default" ]; then
     echo "[goenv] add following lines in your .barshrc/.zshrc"
-    echo "wxport GOROOT=$GOENVGOROOT/default"
+    echo "export GOROOT=$GOENVGOROOT/default"
     echo "export PATH=$PATH:$GOROOT/bin"
     export GOROOT="$GOENVGOROOT/default"
     export PATH="$GOENVGOROOT/default/bin:$PATH"
 
 if ! type git 2>&1 > /dev/null; then
   echo "[goenv] To get goenv, install git"
-  exit 0 
+  exit 0
 fi
 
 echo "[goenv] cloning goenv from GitHub"
 fi
 
 echo "[goenv] install finished."
-exit 0
+exit 0
     unset _OLD_PATH
   fi
 
-  export GOPATH="$_OLD_GOPATH"
- 
+  if [ -n "$_OLD_GOPATH" ]; then
+    export GOPATH="$_OLD_GOPATH"
+    unset _OLD_GOPATH
+  fi
+
   if [ "$1" != "init" ]; then
     unset -f deactivate
   fi
 export GOENVNAME="{{.ENVNAME}}"
 export PS1="{{.PS1}}"
 export GOPATH={{.GOPATH}}
-export PATH={{if .GAE}}"$GAEGO/bin":{{end}}"$GOPATH/bin":$PATH
+export PATH={{if .GAE}}"$GAEGO/bin":{{end}}"$GOPATH/bin"{{if .GOROOT}}:"$GOROOT/bin"{{end}}:$PATH
 {{if .GOROOT}}export GOROOT={{.GOROOT}}{{end}}
 `