Go Help

Post Comments

Comments are welcome.  Please be civil and on point.  You are welcome to point out any errors I have made or make suggestions.  I have limited time for questions, but I will try to answer when I can.  This project follows an “open source” approach for the benefit of anyone.  By posting here, you explicitly give permission for the use of your ideas and code for this project.   I will feel free to link to any pages you reference.


  1. Thanks for sharing it dfaafaekebge

    Comment by Johnf203 — September 2, 2014 @ 1:53 pm | Reply

  2. I noticed that the Go Format v2 command uses the current file to format, even though Input: Current document is selected.

    Here’s what I did (ymmv):
    TMPDIR=$(mktemp -d)
    cat $DOCPATH
    # Now DOCPATH contains the current buffer contents, not the contents at the time of the last save
    # I realize that if you select Save: Current File (as directed :) ) that you essentially get the same thing, but it’s the principle of the thing, right?
    gofmt …

    rm -r $TMPDIR

    Here’s another one that I like, to preview gofmt changes:
    Input: Current document
    Output: Display in bottom pane

    TMPDIR=$(mktemp -d)

    cat $TMPDIR/GoDoc
    gofmt $TMPDIR/GoDoc > $TMPDIR/GoFmt
    diff -u $TMPDIR/GoDoc $TMPDIR/GoFmt
    rm -r $TMPDIR

    Comment by jshipley — March 25, 2010 @ 3:55 am | Reply

    • Thank you for your comment. The idea of saving first was to be conservative, but the idea of checking before saving is interesting. I now use commit with Mercurial liberally, so it is not so much of an issue.

      The diff is a great idea. I have started using ‘meld’ with Mercurial, it might be interesting to build it into GoFormat.

      Comment by jgord — March 28, 2010 @ 6:19 am | Reply

  3. As I followed John Gordon’s gedit tutorial and tried to use gofmt in gedit. I found that if I did not have a CRLF after the last } at the end of my program I would get an /dev/stdin:15:1: expected ‘;’, found ‘EOF’ error in the Shell Ouput box at the bottom of gedit. Hitting enter and putting in the CRLF and gofmt in gedit then worked.

    Comment by expate98 — March 1, 2010 @ 1:42 am | Reply

    • Problem with /dev/stdin:15:1: expected ‘;’, found ‘EOF’ fixed. Seems I forgot to add #!/bin/bash and path to full path tpo MakeGo

      Comment by expate98 — March 1, 2010 @ 5:05 am | Reply

  4. Hi I was reading the technology section of the NY Times this morning and I saw an article on GO and they had a link to you web this web site in the article. :-) I started to learn about go about a month ago. Thanks for the information on how to make Gedit work with Go. Right now I’m using Unbuntu 8.10 and Gedit in my version is missing some of the features. One thing I can’t figure out is on the Build Go script I keep getting /bin/sh: Syntax error: end of file unexpected ” when I run MakeGo but it works fine at the command line. I’ll try upgrading to Unbuntu 9.10 Thanks again

    Comment by expate98 — February 28, 2010 @ 11:28 pm | Reply

    • One thing to be careful with when using #!/bin/sh script files in Ubuntu is that they are executed with dash. Many script authors expect bash and use bash specific features which, as you can imagine, causes problems.

      Comment by Tonic Artos — March 1, 2010 @ 3:15 am | Reply

  5. Hey thanks for these, but i’m having problems, when i try to run either of Go Format, Go Build or Go Run it does not find the commands such as gofmt, 8g, etc.. Could you help? I’m running Ubuntu Netbook Remix 10.04 alpha2.

    Comment by Toni Korpela — February 26, 2010 @ 12:16 am | Reply

    • Hi Tony,

      My guess is environment variables for the Go Format problem. Check out the “Gohelp” chapter “Installation Notes”. A non-interactive terminal does not recognize environment variables set in .bashrc. I put mine in $HOME/.profile. Also Go requires that your binaries be in $HOME/bin or that you set $GOBIN to their location. There was some discussion of this on go-nuts and I think a bug at some point.

      Also, on the ./MakeGo, I have MakeGo in the same directory as my source files. If you have a more involved project structure like the Go files themselves, you will need to change this to point to the location of your build executable. Make sure MakeGo is executable. Hope this helps. If you still have problems let me know.



      Comment by jgord — February 26, 2010 @ 8:21 pm | Reply

  6. Thanks for the props. If you have any comments on how I can improve the go.lang file send me an email or get in touch via the launchpad page. I tried to include as many helpful tips via syntax highlighting – largely string assistance – as I could think of so I hope you find them useful.

    Also, you can should add meld and sed/awk to the list of useful tools to combine with the external tools plugin and zenity.

    Comment by Tonic Artos — February 16, 2010 @ 12:54 pm | Reply

    • Funny you mention this, I have been lazy about adding the next 2 chapters to Version Control. My next chapter adds scripts to Nautilus that I have been using for awhile , probably including Meld. Then I will add a chapter on TortoiseHg integration with Nautilus, I have it installed, it seems to work fine, but has a heavy feel. What ideas do you have for using sed/awk? Also, do you know a good ctags file for Go?


      Comment by jgord — February 16, 2010 @ 8:17 pm | Reply

      • I had some rudimentary scripts that used two sequential zenity dialogs to perform a regular expression replace or find lines. However it turns out the problem is already solved by a number of plugins that can be found on the gedit plugin site which you’ve already mentioned.

        Unfortunately I’ve never gotten around to making ctags work for me. I’m sure it is trivial but I’ve never bothered much.

        About the VCS scripts for Nautilus. I tend to find setting up scripts in the external tools quite satisfactory. The scripts aren’t that great and a plugin for gedit would be better. This is a simple one I use to commit the current files I have been working on to git. I also have others but I find myself using this all the time.

        cd “$GEDIT_DOCUMENT_DIR”
        `test -d .git`
        echo $no_git
        until [[ $no_git == 0 || `pwd` == ‘/’ ]];
        cd ..
        `test -d .git`
        echo ‘ere’
        if [[ !$no_git ]];
        files=( $GEDIT_DOCUMENTS_PATH )
        declare -a valid_files
        for f in ${files[@]};
        if [[ `expr match $f $p` > 0 ]];

        if [[ ${#valid_files[@]} > 0 ]];
        git add ${valid_files[@]}
        git commit ${valid_files[@]} -m “`zenity –entry –text “Please enter the commit message for your changes:\n Root dir is:\n$p/\nFiles with changes are:${valid_files[*]//$p\//\n}”`”
        echo ‘Did not find git repo in directory tree.’

        Comment by Tonic Artos — February 24, 2010 @ 7:13 pm

      • Same for me, I use commit to Mercurial from Gedit the most often. I also use hgLog with Zenity to check the change log, then I use “hg update” from the built-in terminal to go back to a previous version.

        Comment by jgord — February 25, 2010 @ 9:56 pm

  7. Thank you very much for sharing (and inspiring…)

    Comment by Thomas Kristensen — January 22, 2010 @ 1:00 am | Reply

  8. Thank you very much, I want to try this new go, looks promising, with an IDE is always easer, with all this gedit is almost a full ide.

    Comment by Sargate — December 24, 2009 @ 4:33 am | Reply

    • You are welcome. In the next few days, I will be posting completely redone scripts with more options, plus some other hints at making your editing go more smoothly.

      Comment by jgord — December 26, 2009 @ 8:07 am | Reply

  9. Thanks for this how to!

    Just a thing….
    I downloaded the go.lan file and copied it as root to /usr/share/gtksourceview-2.0/language-specs but it didn’t work.
    An additional step is required: give read permission to everyone!

    Have fun and happy Christmas,

    Comment by Alessio — December 15, 2009 @ 9:19 pm | Reply

    • thanks, I added the caveat to the page.

      Comment by jgord — December 16, 2009 @ 3:31 am | Reply

  10. Thanks for the tips! The file browser and external tools made my life easier.

    Since I have my project organized into multiple subfolders and I want to be able to run the tests for the whole project with one command, I wrote for Gedit commands which find the topmost makefile and use it: http://gist.github.com/256946

    Comment by Esko Luontola — December 15, 2009 @ 2:04 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: