|A Programmer's Guide To Go With LiteIDE|
|Written by Mike James|
|Thursday, 14 November 2013|
Page 1 of 4
Google's system programming language Go is becoming more mature and easier to use. Now is a good time to try it out with LiteIDE to make it even easier.
A Programmer's Guide To Go
Part 1 Language Basics
Go is an easy-to-use but surprisingly powerful language. You could call it a modern version of C, but read on and find out what you think of it for yourself. It has a clean and simple structure that is said to be statically typed. but it behaves like a dynamically typed language. It also compiles to native code, but is as easy to work with as an interpreted language.
The bottom line is that it's worth a look and this article tells you all you need to know to get started. In Part 2 we'll take a closer look at how Go deals with objects and concurrency.
All you have to do to set up Go is to download the appropriate binary and extract it to the correct directory and set the Path to point to the location of the bin directory where all of the Go tools live.
If you are using OSX or Windows then there are installers that you can use that will add the appropriate path.
The Windows MSI installer is marked as "experimental" but it seems to work very well and it gives you an instantly working installation - I recommend using it. All you have to do is download and run the most up-to-date 32 bit or 64 bit msi file from the download page.
By default it installs the system in C:\Go
You can check that you have a working system by creating a simple program:
You can use NotePad or any plain text editor and save the file as hello.go. To run it you need to open a console and type:
As an alternative you can move on to install LiteIDE and try running a program from there.
LiteIDE isn't essential for creating Go programs and you will hear programmers saying that it isn't necessary - all you need is an editor. This is true but for the casual programmer an IDE makes getting started easier and once you use LiteIDE you will quickly find that it makes you much more productive.
The only downside is that there is virtually no documentation for using LiteIDE.
All you have to do is download a tarball or a zip from
and unpack it to a suitable folder. If you are using Windows you will need a copy of 7zip to unpack it. You can unpack the program to any folder and it seems to work perfectly but one obvious place to store the liteide folder is within c:\go.
Of course with such minimal installation you don't get a shortcut to run the program so simply open c:\go\liteide\bin and find liteide.exe and create a shortcut or drag it to the taskbar or whatever you find useful.
When you run LiteIDE you will see a welcome screen with some useful links.
You can worry about all the features of LiteIDE later. For the moment let's just get a simple Go program running.
Select File New, from the menu or the New Button in the Welcome screen and in the dialog box that appears select Go1 Command Project. This creates a Go command line project for you in the C:/Go/src directory for you. If you give the project the name Hello it will create the files in C:/Go/src/Hello.
The project template creates the Files, main.go, and doc.go in the project directory and the main.go file contains:
You can run the program using the blue Build and Run button marked BR in the toolbar. You can find a range of commands relating to building and running a program in the Build menu option and by dropping down the B and BR button menus.
If you run the program you can see the result in the Build Output window at the bottom.
If this doesn't work the only possibilities are that you haven't created a default command line project or the Path is incorrectly set.
There are many other feature in LiteIDE that you can explore but now you have enough to put Go though its paces.
Variables And Simple Data Types
Go has all of the primitive data types you might expect from uint8 to float64.
The big surprise is that it supports a complex numeric type:
And if you are wondering what a rune is then the mystery is solved once you know that t rune is used to store a Unicode code point. In other words, rune is Go's equivalent of a character type.
You can also make use of uint, int and uintptr which are machine dependent integers with either 32 or 64 bits.
|Last Updated ( Thursday, 09 January 2014 )|