import "git.apache.org/thrift.git/lib/go/thrift" func writeListEndToBinaryProtocol(proto thrift.TProtocol) error { _, err := proto.WriteListBegin(thrift.STRING, 3) if err != nil { return err } _, err = proto.WriteString("a") if err != nil { return err } _, err = proto.WriteString("b") if err != nil { return err } _, err = proto.WriteString("c") if err != nil { return err } err = proto.WriteListEnd() if err != nil { return err } return nil }
import "git.apache.org/thrift.git/lib/go/thrift" func writeListEndToCompactProtocol(proto thrift.TProtocol) error { _, err := proto.WriteListBegin(thrift.I32, 4) if err != nil { return err } _, err = proto.WriteI32(1) if err != nil { return err } _, err = proto.WriteI32(2) if err != nil { return err } _, err = proto.WriteI32(3) if err != nil { return err } _, err = proto.WriteI32(4) if err != nil { return err } err = proto.WriteListEnd() if err != nil { return err } return nil }In this example, we are writing the end of a Thrift list of integers to a compact protocol using the WriteListEnd method.