Go Help

Gedit – An IDE for Go

Above is my basic desktop layout.

  1. Notice on the left I have Nautilus File Manager, it has tabs for the directories I am using.   It is also showing the Mercurial Version Control status of my project files.  This is done with the Mercurial integration into Nautilus called tortoiseHg.  With this I can manage Mercurial from within Nautilus.  From here I can open Go files to edit or to run, or I can graphically show the difference between any 2 files.
  2. Next over you see one instance of gEdit, here showing documentation from the ‘godocs’  utility that has been called from inside gEdit with 1 keystroke.  Notice the syntax highlighting with the documentation and multiple tabs.
  3. Next you see some popups.  One shows a graphed version of the Mercurial log and the other the status of the last Build.  Both of these were run from within gEdit with 1 keystroke.
  4. At the right, is my main edit instance of gEdit.  Note that you can have the same document open in multiple instances of gEdit, I think a better option than a split screen.  gEdit will coordinate the update status of both instances.

From within gEdit I have :

  • syntax highlighting
  • block commenting
  • block indents
  • snippets for code inserting
  • bracket matching
  • automatic indentation
  • an embedded terminal
  • saved sessions
  • a side file pane
  • tear off tabs (an undocumented gEdit feature)

I can also with 1 keystroke:

  • Build Go Code, with pop up or Meld Graphical Diff viewer for errors
  • With gEdit 2.30.4, you can jump directly to to code errors from links in the bottom pane.  See GoBuild.
  • Run Go Code
  • Format Go Code, with pop up or Meld Graphical Diff viewer for errors
  • Display Go Package Documentation

For Mercurial Version Control 1 keystroke for:

  • Add
  • Commit
  • Graph Log
  • Rollback
  • Status
  • Show difference between current edit and the last commit with Meld Graphical diff viewer

These are just some of the things you can do to customize gEdit.  The Chapters on this site document how to do much of this.


Gedit is a light weight text editor that comes with the Linux Gnome Desktop Manager from the Gnome Project. As you can see from the above, gEdit it can be configured to be a quite full featured IDE.  The purpose of this article is to give some ideas for using Gedit as an IDE (Integrated Development Environment) for the new Google language Go.  For information about other editor options see links page.

This is a work in progress that I am continuing to enhance.  Expand upon these ideas and feel free to Post a Comment with new ideas.  I cover the following:

  1. Gedit Basic Settings
  2. Gedit Plugins
  3. Gedit Syntax Highlighting
  4. Gedit External Tools
  5. Go Format
  6. Go Build
  7. Go Run
  8. Go Doc
  9. Mercurial Version Control

Assumptions and Conventions

I run Ubuntu Linux 9.10 64 bit, but these techniques should work with Gedit on any Linux Gnome system.  I assume that you have some knowledge of Linux, including directories (folders), permissions, the environment, and simple shell scripting.   I try to write the shell scripts simply without nesting or shortcuts and with plenty of comments.

I assume that you have successfully installed and set up Go and written, compiled and run the obligatory “Hello World” program.  On my links page you will see sources that can help with these things.  When I use the term File Manager, I am using Gnome’s Nautilus (on Ubuntu, that is what you get when you click Places).  I try to give examples using both the GUI and Gnome Terminal.

I recommend that you set your environment variables in ‘$HOME/.profile‘ to save yourself a lot of grief using non-interactive shell sessions.  Some of the scripts I have created use ‘tmp’ files.  I try to clean them up after use, but, I personally prefer to have a ‘$HOME/MyTemp‘ directory to keep things from getting cluttered,  just in case.  The scripts look for an environment variable ‘MyTemp‘ with a path to a temp directory (ie. export MyTemp=$HOME/MyTemp), if not set, they will use the current document directory.  See the Chapter Installation Notes.

For ease of getting stated, I follow the procedures outlined in the Go tutorial and other Go documentation.  For example, I am using the 6g, 6l (8g, 8l) compiler and having all working files in one directory.  Your project directory can be where ever you wish, Go will find what it needs following the environment variables.

Not Working?

If something isn’t working, check the normal culprits.

  1. Did I type something incorrectly?
  2. Is my PATH variable set correctly in my environment?  Open a terminal and type “env”.
  3. Are my Go environment variables set and in scope?  GOOS, GOARCH, GOROOT.
  4. Are file permissions properly set?  If a file needs to execute, it it set to executable?

Legal Stuff

  1. You are free to use the ideas and code in this article as you wish.  However, I make no representation that they are good for anything.  Use at your own risk.
  2. If you wish to quote this article, you can do so under “fair use”.  This content on this site is licensed under Creative Commons Attribution 3.0, please link back and give this article credit.

This content on this site is licensed under Creative Commons Attribution 3.0

Create a free website or blog at WordPress.com.

%d bloggers like this: