package main import ( "fmt" "google.golang.org/protobuf/proto" ) func main() { s1 := &Student{} //��һ��ѧ����Ϣ s1.Name = "jz01" s1.Age = 23 s1.Address = "cq" s1.Cn = ClassName_class2 //ö�����͸�ֵ ss := &Students{} ss.Person = append(ss.Person, s1) //����һ��ѧ����Ϣ���ӵ�Students��Ӧ����Ƭ�� s2 := &Student{} //�ڶ���ѧ����Ϣ s2.Name = "jz02" s2.Age = 25 s2.Address = "cd" s2.Cn = ClassName_class3 ss.Person = append(ss.Person, s2) //���ڶ���ѧ����Ϣ���ӵ�Students��Ӧ����Ƭ�� ss.School = "cqu" fmt.Println("Students��ϢΪ��", ss) // Marshal takes a protocol buffer message // and encodes it into the wire format, returning the data. buffer, _ := proto.Marshal(ss) fmt.Println("���л�֮�����ϢΪ��", buffer) // Use UnmarshalMerge to preserve and append to existing data. data := &Students{} proto.Unmarshal(buffer, data) fmt.Println("�����л�֮�����ϢΪ��", data) }