# Write Your Go Programs Using GEdit

- Published: November 23, 2013
- Author: William Kennedy
- URL: https://www.ardanlabs.com/blog/2013/11/write-your-go-programs-using-gedit.html

<i><b>This is a guest post from Tad Vizbaras from&nbsp;<a href="http://www.etasoft.com/" target="_blank">Etasoft</a>&nbsp;in South Florida.</b></i>
<br />
<br />
There are a number of editors and IDEs for Go development. LiteIde, Vim, Emacs and GEdit just to name a few. Each developer has their own favorite editor for each language they work with. Some like full featured IDE environments while others prefer speed over features. My personal&nbsp;favorite&nbsp;editors for Go development at the moment are Vim and GEdit.<br />
<br />
GEdit comes as part of many Linux distros. If you use Ubuntu, it is part of the operating system. GEdit has some decent features like:<br />
<br />
&#42; Syntax Highlighting<br />
&#42; Split Windows<br />
&#42; Word Wrapping<br />
<br />
Advanced features are left to be handled by external plug-ins.<br />
<br />
I prefer project-less development. That means there are no formal project files and projects are preserved via a workspace bound to a directory structure. Go has excellent support for project-less development. When building and installing your projects, the Go tooling, in conjunction with the way Go packages code, can minimize the need for external scripts and makefiles.<br />
<br />
GEdit is a decent editor but I could not find any good Plug-ins that would allow me to perform a Go build right from the editor. The &quot;External Tools&quot; Plug-in has worked for me. I was able to set up shortcuts and get &quot;go build&quot; to execute. When you click on errors, displayed in the bottom pane of GEdit, the cursor jumps to exact error location.<br />
<br />
When I started programming in Go, the &quot;External Tools&quot; Plug-in worked for me for quite some time. But after awhile, I started to wish that &quot;go build&quot; would run similar to how Linters ran. With Linters, you can run a command after the file is saved. Since Go usually takes only few seconds to build, the Plug-in could execute a &quot;go build&quot; on save and then jump to the error location if there were any.<br />
<br />
I wrote a GEdit Plug-in that is developed in Python. Depending on the version of Python you have installed, you may require some small adjustments. This is covered in the Known Issues section below.<br />
<br />
Ops, I forgot to mention... Go is Awesome. But you probably already know that.<br />
<br />
<b><span style="font-size: large;">Meet GoBuild for GEdit 3.x</span></b><br />
GoBuild - GEdit 3 Plug-in for Go (golang) development.<br />
<br />
GoBuild Plug-in version 1.0 for GEdit. Plug-in attaches to the <b>on_save</b> event in GEdit for Go source code files only. It does nothing for any other file type.<br />
<br />
It will run &quot;go build&quot; after the file is saved. If the current filename has &quot;_test.go&quot; in the name, then the Plug-in will run &quot;go test&quot; against the current file's directory. The Plug-in will wait a number of seconds for the build or test to complete. It will timeout and quit the build or test so GEdit will not freeze.<br />
<br />
<b><span style="font-size: large;">Images</span></b><br />
Plug-in captures &quot;go build&quot; errors and shows them in the Gedit status bar. It also jumps to the first error and highlights error line if error is in the current file.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">

<a href="../../../images/goinggo/gobuildscreen1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><span class="sr-only">View linked image: Screen Shot</span>![Screen Shot](../../../images/goinggo/gobuildscreen1.png)</a>

</div>
<br />
Plug-in shows the last successful build.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">

<a href="../../../images/goinggo/gobuildscreen2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><span class="sr-only">View linked image: Screen Shot</span>![Screen Shot](../../../images/goinggo/gobuildscreen2.png)</a>

</div>
<br />
Plug-in shows any &quot;go test&quot; failures.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">

<a href="../../../images/goinggo/gobuildscreen3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><span class="sr-only">View linked image: Screen Shot</span>![Screen Shot](../../../images/goinggo/gobuildscreen3.png)</a>

</div>
<br />
<br />
<b><span style="font-size: large;">Download</span></b><br />
I have posted the plugin on GitHub. Please send any feedback you may have.
<br />
<a href="https://github.com/tadvi/gedit-gobuild" target="_blank"><span class="sr-only">External resource on github.com: </span>https&#58;//github.com/tadvi/gedit-gobuild</a><br />
<br />
<b><span style="font-size: large;">Know Issues</span></b><br />
Has been tested on Ubuntu 13.04 and 13.10.<br />
<br />
Ubuntu 13.10 requires small change in the gobuild.plugin.<br />
Line with python should be changed to python3 like below:<br />
<br />
Loader=python3<br />
<br />
This is because Gedit seems to default on using python 3 instead of<br />
python 2.7 on newer versions of Linux.<br />
<br />
<b><span style="font-size: large;">Usage</span></b><br />
&nbsp;&#42; Simply drop files into ~/.local/share/gedit/plugins .<br />
&nbsp;&#42; If this directory does not exist - create it.<br />
&nbsp;&#42; Start GEdit<br />
&nbsp;&#42; Open Edit-Preferences, then plug-ins and check &quot;GoBuild after save&quot; plug-in.<br />
<br />
<b><span style="font-size: large;">Notes</span></b><br />
<div>
&nbsp;&#42; Current build directory is determined based on the active open source file.<br />
&nbsp;&#42; Plug-in is designed for fast development on small to mid size projects.<br />
&nbsp;&#42; Source code file is built with every save.<br />
&nbsp;&#42; Tight iteration of the save-edit-save-edit cycle.<br />
&nbsp;&#42; Not designed for large Go projects because compilation will timeout if it takes too long.<br />
&nbsp;&#42; Not designed for Go unit tests that take a long time to run.<br />
&nbsp;&#42; If you work on Go projects with build times over 5 seconds, this plug-in should be modified<br />
&nbsp; &nbsp; to use keyboard shortcut (such as 'F5') instead of on_save action.</div>
<br />
