samuel/go-thrift — pull request #30 by wuman (2013-11-27 18:17:18+00:00)
Title: add NewStruct() with default field values

Thrift defines default values for a struct. This patch adds in the generator a `NewStruct()` function which fills the default values for fields within a struct.

For instance, a `struct` in the `Hbase.thrift` file called `Mutation` has some fields with default values:

struct Mutation {
1:bool isDelete = 0,
2:Text column,
3:Text value,
4:bool writeToWAL = 1
}

The patch would generate the following:

type Mutation struct {
IsDelete bool `thrift:"1,required" json:"isDelete"`
Column []byte `thrift:"2,required" json:"column"`
Value []byte `thrift:"3,required" json:"value"`
WriteToWAL bool `thrift:"4,required" json:"writeToWAL"`
}

func NewMutation() *Mutation {
return &Mutation{
isDelete: 0,
writeToWAL: 1,
}
}