The Buttons

The basic use is to enter/edit your code, click Compile, then fix any errors. When you get a clean compile, click Run. Your program will execute in a 'Dos' window.

The Compile Button - saves your code, then runs the compiler. If you have an error in the area of package importing, syntax errors lower down are not reported, so fix the package stuff first! Also, you might get a compilation error which refers to another file (e.g. an imported one.) You can open another copy of gogo to look at the file.

The Run Button - runs the program.

The Go Fmt button runs the Go source-code formatter/indenter on the current file. Your code needs to have been compiled (i.e. no syntax errors). Gogo does not allow formatting without a clean compile. If the file that you are formatting is part of a packages with other files in the same folder, all the files are formatted.

The Compile Pkg button lets you compile a group of source files into one package - most of your packages will be in one file, so you might not use this often.

Do this by creating a directory under the src folder, with the exact same name as your package. Put all the package files in this directory (no others should be put there) An example is shown below.

Initially, compile each file separately, to remove trivial errors. Then, with any of the package files loaded into gogo, click on Compile Pkg. When the package compiles properly, it will be 'installed' and is ready for use.

You might get compilation errors from ANY file, not only the one currently loaded, so take care with this.

The File menu

Open, Save, Save As, Print, Exit have their normal meanings. NB the Compile button also does a save.

New Go File creates a 'hello world' program, and forces you to save it before you start compiling. The file must be stored in a folder of the same name as the file, and under the \src folder. You cannot start typing into the editor without creating a new file, or opening an existing one.

New Go Package creates a package file, which you need to edit. It laso provides guidance on how to proceed with your package.

The Edit menu

... have their normal meanings.

The Tools menu

Lines Containing - really a simplified grep.

Set Command-Line Args - Used to pass data to programs when they are launched. If one of your args contains spaces, then "quote" them. Here is a line with 3 args:

cat "a dog" fish

Bigger/smaller text - obvious.

Black/white - switches the editor scren from black-on-white to white-on-black and vice-versa.

Show/hide issued commands - displays the call to the go command, which is used to run the compiler etc.

The Help menu

Most of these link to websites.

Bugs, Features, Issues

Some of these are possible to fix/include, some are not. Some depend on the Windows port, which is out of my control.

  • 1 mar 12 - Syntax highlighting - uses Java's reserved words list. Quite possible to change. Sometime...

A Package Example

We require that a program stoed in mainDemo.go makes use of two packages. Here is how we set this up.

The GOPATH variable refers to c:\mygo. Inside this, we create folders named bin, pkg, src. We choose to put our program and its packages inside an outer folder, called gogoPackageDemo

One package is named mypackage. The other is named mypackage2, and is stored in a lower-level folder, just to show you that we can do this. The package neames and file/folder names must mach, as shown below:

      src folder
            gogoPackageDemo folder
                  mainDemo folder

                  mypackage folder
                        mypackagex.go   (you can choose any names for these files)
                  mypackage2folder folder
                        mypackage2 folder
                              mypackage2stuff.go   (any names allowed for this file)
Here is a listing of the files.  

package main

import (

func main() {
	fmt.Print("in mainDemo.\n")
	//now use the two packages:
	fmt.Print("leaving mainDemo.\n")


package mypackage
import "fmt"	
func Func1x() { 

    fmt.Print("(multi-file package - in Func1x - mypackage\n")
    fmt.Printf("leaving x-mypackage\n")

package mypackage
import "fmt"

func Func1y() {
    fmt.Print("in Func1y-mypackage\n")
    fmt.Print("leaving y-mypackage\n")

package mypackage2
import "fmt"	 

func Func2() { 
    fmt.Printf("in  Func2 of mypackage2, and leaving now.\n")

Note that though you can choose any names for package files, they must contain a package statement at the top.