Like lot of new things, Google has launched their new programming language... "Go"...
Nice name, ha! Whether it will go a long way or a short one... only time will tell...
So, I thought I will give it a try... in Ubuntu 9.10 Karmic Koala...
1. Installing Go in Ubuntu
Adding Environment variables...$ echo 'export GOROOT=$HOME/go' >> ~/.bashrc
$ echo 'export GOOS=linux' >> ~/.bashrc
$ echo 'export GOARCH=386' >> ~/.bashrc
$ echo 'export GOBIN=$GOROOT/bin' >> ~/.bashrc
$ echo 'export PATH=$PATH:$GOBIN' >> ~/.bashrc
$ . ~/.bashrc
Installing...$ sudo apt-get -y install mercurial
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
$ sudo apt-get -y install bison gcc libc6-dev ed
$ cd $GOROOT/src
$ mkdir $GOBIN
$ ./all.bash
Total download around 10 MB... After around 12 minutes, the install will finish and 'Go' will be up and running... You can put all the above steps into a shell script and run it... :) Wow... it have inbuilt crypto libraries too...
2. Programming in Go
Source file : *.go
Compiler : 8g (for 386)
Compiled file : *.8 (for 386)
Linker : 8l (for 386)
Output : 8.out
Hello World!!!$ cat >hello.go <<EOF
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
EOF
$ 8l hello.8
$ ./8.out
hello, world
That was easy... :) Phew !!!
OR
We can use gccgo
, gccgo is slower but more efficient... installing gccgo...$ mkdir gccgo
$ sudo apt-get -y install subversion
$ svn checkout svn://gcc.gnu.org/svn/gcc/branches/gccgo gccgo
It is actually taking too much time... I will come to that later...
Did you know there is a gcc test suite called "gcc-torture" ? :)
Update: I actually installed gccgo... gccgo is up and running...
3. Let's review...
Examples in [brackets]...
- package
from Java [package main
]
- import
from Java/Python [import fmt "fmt"
]
- Comments same as C++
- No terminator
- C style func
[func main()
]
- C style braces ({})
- There are typed and untyped variables/constants [var s string = "";
]
- var
for declarations
- Grouping of same datatype declarations, separated by semicolon (;)
Just this much for now...
The verdict... nothing for now... but I am gonna learn the language... :)
Reference: Installing Go
Thursday, November 12, 2009
Google Go - A First Look
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment