Friday, April 23, 2010

gostrutils

gostrutils is a package for the Go programming language with StringTokenizer and StringBuffer similar to the ones in java.

project site is code.google.com/p/gostrutils.

Monday, April 12, 2010

gopages - my simple web framework for Go Programming Language

I'm used to php way of coding web pages where you embed your codes in <?php ?> tags. So I'm trying to emulate such feature in Go with gopages.



You can visit the project home at http://code.google.com/p/gopages.

All comments are welcomed.

Thursday, April 8, 2010

Compact Diary

Compact Diary is available for download at project site .

Just like the name, it is a password protected diary where you can store your daily toughts.

You can even publish to blogger with it.

You can check it out.

Ubuntu 10.04 LTS

Ubuntu 10.04 LTS beta 1 was released some days ago and I've been really impressed with everything, the theme, the booting speed and better performance with my ATI graphic card. But the only thing I missed is the absence of GIMP but it can still be installed with synaptic or apt-get.

My wireless wasn't recognised after installation but was fixed by just installing the bcmwl-kernel-source using synaptic and the 10.04 cd or iso as the repository.

Can't wait for the stable release








Friday, April 2, 2010

Google provides Protocol Buffers for Go Lang

Google Go Programming Language that was released last November has really impressed me and others worldwide if u've been monitoring it.

But the inclusion of the Protocol Buffer Library is a boost for people like me who prefers serializing to other technologies like XML. I believe I will have cleaner syntax with less lines of code compared to using XML.

For those interested in using Protocol Buffers with Go Lang, visit this link or if you prefer using it with other languages like Java, Python and C++, visit the project homepage here.


The simplest way to describe this is to see an example. Given file test.proto, containing


package example;

enum FOO { X = 17; };

message Test {
required string label = 1;
optional int32 type = 2 [default=77];
repeated int64 reps = 3;
optional group OptionalGroup = 4 {
required string RequiredField = 5;
};
}


The resulting file, test.pb.go, is:


package example

import "goprotobuf.googlecode.com/hg/proto"

type FOO int32
const (
FOO_X = 17
)
var FOO_name = map[int32] string {
17: "X",
}
var FOO_value = map[string] int32 {
"X": 17,
}
func NewFOO(x int32) *FOO {
e := FOO(x)
return &e
}

type Test struct {
Label *string "PB(bytes,1,req,name=label)"
Type *int32 "PB(varint,2,opt,name=type,def=77)"
Reps []int64 "PB(varint,3,rep,name=reps)"
Optionalgroup *Test_OptionalGroup "PB(group,4,opt,name=optionalgroup)"
XXX_unrecognized []byte
}
func (this *Test) Reset() {
*this = Test{}
}
func NewTest() *Test {
return new(Test)
}
const Default_Test_Type int32 = 77

type Test_OptionalGroup struct {
RequiredField *string "PB(bytes,5,req)"
XXX_unrecognized []byte
}
func (this *Test_OptionalGroup) Reset() {
*this = Test_OptionalGroup{}
}
func NewTest_OptionalGroup() *Test_OptionalGroup {
return new(Test_OptionalGroup)
}

func init() {
proto.RegisterEnum("example.FOO", FOO_name, FOO_value)
}


To create and play with a Test object:

package main

import (
"log"

"goprotobuf.googlecode.com/hg/proto"
"./example.pb"
)

func main() {
test := &example.Test {
Label: proto.String("hello"),
Type: proto.Int32(17),
Optionalgroup: &example.Test_OptionalGroup {
RequiredField: proto.String("good bye"),
},
}
data, err := proto.Marshal(test)
if err != nil {
log.Exit("marshaling error:", err)
}
newTest := example.NewTest()
err = proto.Unmarshal(data, newTest)
if err != nil {
log.Exit("unmarshaling error:", err)
}
// Now test and newTest contain the same data.
if proto.GetString(test.Label) != proto.GetString(newTest.Label) {
log.Exit("data mismatch %q %q", proto.GetString(test.Label), proto.GetString(newTest.Label))
}
// etc.
}