The next logical step is to run your program from within Gedit with one keystroke.
- If you have not done so already, go back to the Chapter Plugins and install External Tools.
- In Gedit go to Tools>Manage External Tools.
You should see a screen similar to below. If you have followed the previous Chapters, this is old hat.
- Go to the bottom left of the window and click on the icon just above the help button. This will create a new tool waiting for input of a name. Give it a name, I used ‘Go Run’.
- Go to the right hand panel and enter the code on the screen shot. Or copy and paste from here.
# Runs Go program in current Gedit tab
# Output in bottom pane
# Strip ‘.go’ and append “.out” to source file name
Below the code panel you can set:
Just press the key combination you want to use to for Go Run. Also, if there is conflict with another tool, click on that tool name, more to the shortcut key field and change it, or press backspace to erase the shortcut.
Set this to nothing or current document if you wish to save your file before it is run. It was already saved when you compiled.
Set this to nothing. $GEDIT_CURRENT_DOCUMENT_NAME is used to get the document name.
Set this to display in bottom pane.
Choose for your situation.
Above the Close Button, you can make your tool language specific. If you installed the syntax highlighter previously, Go will come up as one of your language choices. This creates a new language category or adds your tool to an existing one in the left pane. You can set your new Tool to Go. If you set it to ‘all languages’, then it will always come up on the Tools>External Tools drop down box. I changed the built in Tools ‘Build’ and the ‘Remove Trailing Spaces’ to C. Now they don’t come up on the Tools>External Tools when I am editing Go.
Open Gedit. Enter some source code. Compile and Link, then Press your Go Run shortcut key, or go to the menu and go to Tools>External Tools>Go Run. You should see the output of your program in the bottom panel.