Go Help

Go Build V2


The Go Build Chapter showed a basic External Tool for Compile and Link.   This is a much more complete script that does the following.

  1. Handles file and directory names with spaces (not a recommended practice).
  2. Allows the Compile and Link Messages  to display to the Bottom Pane, a New Tab, a Pop up Terminal or a Pop up Window.
  3. NOTE:  With gEdit 2.30.4, you can now go to the error line in your code.  Set OUTPUT=1 and Display in Bottom Pane.  Just click on the error in the botton pane.


  1. Make sure that you have Zenity installed.  See the end of the Plugins Chapter.
  2. If you have a general ‘temp’ directory, set it as described in the introductory chapter.
  3. Open Gedit and Go to Tools>Manage External Tools.
  4. Choose Go Build, or create a new tool.
  5. Copy and Paste the script below into the code panel, overwriting the existing code.
  6. Make the other settings as documented in ‘Tool Settings’ in the script below.
  7. Set the OUTPUT switch below ‘Tool Settings’ in the script below.
  8. Use MakeGo from the Go Build Chapter or roll your own.

# Go Build - Calls your make file Shell Script
#            Creates executable of '$DOCPATH.out'
#   Manual - www.gohelp.wordpress.com - 'Gedit - An IDE for Go'
#   *Tool Settings: Save = Current Document, Input = nothing,
#                   OutPut = see below
#           Set Tool Output to:
#OUTPUT=1  Bottom Pane or Create New Document - save to file, Display
#OUTPUT=2  Bottom Pane - for script error     - save to file, Popup Terminal
#OUTPUT=3  Bottom Pane - for script error     - save to file, Popup Window
OUTPUT=3    # Set OUTPUT Switch

DOCPATH="${GEDIT_CURRENT_DOCUMENT_PATH//%20/ }" # ex tool puts %20 for spaces

if  ! ( test -z "$MyTemp" ) # if MyTemp exists in environment
    TMPDIR="${DIR}"  # else set TMPDIR to current document directory

"${DIR}"/MakeGo "${DOCPATH}" > "${TMPDIR}"/GoBuild.tmp

case $OUTPUT in
    1) cat "${TMPDIR}"/GoBuild.tmp
    2) TermCmd="less \"${TMPDIR}\""/"GoBuild.tmp"
       gnome-terminal --command "${TermCmd}" -t "Go Build" &  # Note & at end
    3) nLines=`wc -l "${TMPDIR}"/GoBuild.tmp|awk '{print $1}'`
       if [ "${nLines}" -gt 28 ]
       zHeight=$(( nLines * 25 ))

       longLine=`wc -L "${TMPDIR}"/GoBuild.tmp|awk '{print $1}'`
       if [ "${longLine}" -gt 80 ]
       zWidth=$(( longLine * 9 ))

       zenity --text-info \
           --height=${zHeight} \
           --width=${zWidth} \
           --title="Go Build" \
           --filename="${TMPDIR}"/GoBuild.tmp \ &

    *) echo "Please Set Go Build OUTPUT option"

sleep 1   # make sure new shells have displayed, then exit
rm "${TMPDIR}"/GoBuild.tmp

Blog at WordPress.com.

%d bloggers like this: