GoLang

(Initial version of the golang page about the golang support and creation of a hello world application on the target)
(wikify and categorize)
 
Line 1: Line 1:
-
= golang =
+
This is a small Wiki page about the [http://maemo.org/packages/view/golang/ golang package] on Maemo. The package contains the standalone go compiler and libraries targeting armv6.
-
 
+
-
This is a small Wiki page about the golang package on maemo. The package
+
-
contains the standalone go compiler and libraries targeting armv6.
+
== Creating a Hello world application using the go programming language ==
== Creating a Hello world application using the go programming language ==
-
Creating a Hello world application using the go language created by google http://golang.org/ on the N900. The go compiler and libraries for maemo are packaged in a package called golang that can be installed from the fremantle/free repository. The package puts all it's content in a directory called /opt/go to follow maemo packaging policies.
+
Creating a Hello world application using the [http://golang.org/ go language] on the [[Nokia N900|N900]]. The go compiler and libraries for Maemo are packaged in a package called <code>golang</code> that can be installed from the fremantle/free repository. The package puts all its content in a directory called <code>/opt/go</code> to follow Maemo packaging policies.
Once the package is installed we need to set a few environments variables to make the go compiler happy.
Once the package is installed we need to set a few environments variables to make the go compiler happy.
Line 24: Line 21:
-
Now off to create Hello world. We will create a directory in the users home directory create a small go hello world file , compile,link and run it.
+
Now off to create Hello world. We will create a directory in the users home directory create a small go hello world file, compile, link and run it.
Creating the directory using mkdir
Creating the directory using mkdir
Line 61: Line 58:
  Hello, Maemo
  Hello, Maemo
-
If all went well you just ran your first go code on maemo!
+
If all went well you just ran your first go code on Maemo!
 +
 
 +
[[Category:Development]]

Latest revision as of 13:50, 31 May 2010

This is a small Wiki page about the golang package on Maemo. The package contains the standalone go compiler and libraries targeting armv6.

[edit] Creating a Hello world application using the go programming language

Creating a Hello world application using the go language on the N900. The go compiler and libraries for Maemo are packaged in a package called golang that can be installed from the fremantle/free repository. The package puts all its content in a directory called /opt/go to follow Maemo packaging policies.

Once the package is installed we need to set a few environments variables to make the go compiler happy.

Those are:

export GOROOT=/opt/go
export GOOS=linux
export GOARCH=arm
export GOBIN=/opt/go/bin
export GOPKG=/opt/go/pkg
PATH=$PATH:$GOBIN

The packager provides a script to to this that can be sourced

~ $ . /opt/go/bin/go_profile


Now off to create Hello world. We will create a directory in the users home directory create a small go hello world file, compile, link and run it.

Creating the directory using mkdir

mkdir hello_go

Go into that directory and fire up an editor

cd hello_go
vi hello.go

Paste the following

package main
 
import "fmt"
 
func main() {
  fmt.Printf("Hello, Maemo\n")
}


exit vi and compile hello.go

~/hello_go $ 5g hello.go

Link it against the go libs (the output is a staticaly linked binary)

~/hello_go $ 5l hello.5

and now run it

~/hello_go $ ./5.out
Hello, Maemo

If all went well you just ran your first go code on Maemo!