student.proto 583 B

1234567891011121314151617181920
  1. syntax="proto3"; //版本号
  2. package student; //包名
  3. option go_package = ".;student";
  4. enum ClassName{ //枚举
  5. class1=0; //标号 必须从 0开始
  6. class2=1;
  7. class3=2;
  8. }
  9. message Student{ //消息,对应于Go的结构体
  10. string name=1; //1:标号,唯一 即可(相当于数据库中的Id,不一定要从1 ,2的顺序依次排列。)
  11. int32 age=2; //必须指定整型的范围,如int32,int64
  12. string address=3;
  13. ClassName cn=4;
  14. }
  15. message Students{
  16. repeated Student person=1; // repeated 修饰,相当于Go中切片
  17. string school=2;
  18. }