import ( "github.com/glycerine/go-capnproto" ) func main() { seg := capn.NewBuffer(nil) rootPtr := capn.NewRootStruct(seg, MyStruct{}) // rootPtr is now a pointer to a new instance of MyStruct }
import ( "github.com/glycerine/go-capnproto" ) func main() { seg := capn.NewBuffer(nil) rootPtr := capn.NewRootStruct(seg, capn.Object([]capn.Field{ capn.Struct(0, capn.Struct{...}), capn.Pointer(1, capn.NewText("hello")), })) // rootPtr is now a pointer to a new object with two fields }In this example, we create a new object with two fields by passing a slice of `capn.Field` objects to `capn.Object`. The first field is a struct and the second field is a text pointer. Note: The examples provided assume that the `MyStruct` type and `capn.Struct` and `capn.Pointer` functions have been defined elsewhere in the code.