diff --git a/go.mod b/go.mod index 5669cf1f..9e12be04 100644 --- a/go.mod +++ b/go.mod @@ -89,7 +89,7 @@ require ( golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.1.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.28.1 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/proto/apiv2/example.proto b/proto/apiv2/example.proto new file mode 100644 index 00000000..ac4dc7a2 --- /dev/null +++ b/proto/apiv2/example.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package memos.apiv2; + +option go_package = "gen-go/apiv2"; + +// Person is a simple message type containing information about a person. +// It is an example of the kind of message that one might define in a protobufs file. +message Person { + string name = 1; + int32 id = 2; +} diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml new file mode 100644 index 00000000..1454b7f4 --- /dev/null +++ b/proto/buf.gen.yaml @@ -0,0 +1,5 @@ +version: v1 +plugins: + - plugin: go + out: gen-go + opt: paths=source_relative diff --git a/proto/buf.yaml b/proto/buf.yaml new file mode 100644 index 00000000..ece50e92 --- /dev/null +++ b/proto/buf.yaml @@ -0,0 +1,10 @@ +version: v1 +name: buf.build/yourselfhosted/memos +breaking: + use: + - FILE +lint: + use: + - DEFAULT + except: + - PACKAGE_DIRECTORY_MATCH diff --git a/proto/gen-go/apiv2/example.pb.go b/proto/gen-go/apiv2/example.pb.go new file mode 100644 index 00000000..0211478a --- /dev/null +++ b/proto/gen-go/apiv2/example.pb.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.29.0 +// protoc (unknown) +// source: apiv2/example.proto + +package apiv2 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Person is a simple message type containing information about a person. +// It is an example of the kind of message that one might define in a protobufs file. +type Person struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *Person) Reset() { + *x = Person{} + if protoimpl.UnsafeEnabled { + mi := &file_apiv2_example_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Person) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Person) ProtoMessage() {} + +func (x *Person) ProtoReflect() protoreflect.Message { + mi := &file_apiv2_example_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Person.ProtoReflect.Descriptor instead. +func (*Person) Descriptor() ([]byte, []int) { + return file_apiv2_example_proto_rawDescGZIP(), []int{0} +} + +func (x *Person) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Person) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +var File_apiv2_example_proto protoreflect.FileDescriptor + +var file_apiv2_example_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x76, 0x32, 0x22, 0x2c, 0x0a, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, + 0x42, 0x0e, 0x5a, 0x0c, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x76, 0x32, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_apiv2_example_proto_rawDescOnce sync.Once + file_apiv2_example_proto_rawDescData = file_apiv2_example_proto_rawDesc +) + +func file_apiv2_example_proto_rawDescGZIP() []byte { + file_apiv2_example_proto_rawDescOnce.Do(func() { + file_apiv2_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_apiv2_example_proto_rawDescData) + }) + return file_apiv2_example_proto_rawDescData +} + +var file_apiv2_example_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_apiv2_example_proto_goTypes = []interface{}{ + (*Person)(nil), // 0: memos.apiv2.Person +} +var file_apiv2_example_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_apiv2_example_proto_init() } +func file_apiv2_example_proto_init() { + if File_apiv2_example_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_apiv2_example_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Person); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_apiv2_example_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_apiv2_example_proto_goTypes, + DependencyIndexes: file_apiv2_example_proto_depIdxs, + MessageInfos: file_apiv2_example_proto_msgTypes, + }.Build() + File_apiv2_example_proto = out.File + file_apiv2_example_proto_rawDesc = nil + file_apiv2_example_proto_goTypes = nil + file_apiv2_example_proto_depIdxs = nil +} diff --git a/proto/gen-go/store/tag.pb.go b/proto/gen-go/store/tag.pb.go new file mode 100644 index 00000000..69eca926 --- /dev/null +++ b/proto/gen-go/store/tag.pb.go @@ -0,0 +1,151 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.29.0 +// protoc (unknown) +// source: store/tag.proto + +package store + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Tag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + CreatorId int32 `protobuf:"varint,2,opt,name=creator_id,json=creatorId,proto3" json:"creator_id,omitempty"` +} + +func (x *Tag) Reset() { + *x = Tag{} + if protoimpl.UnsafeEnabled { + mi := &file_store_tag_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Tag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tag) ProtoMessage() {} + +func (x *Tag) ProtoReflect() protoreflect.Message { + mi := &file_store_tag_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tag.ProtoReflect.Descriptor instead. +func (*Tag) Descriptor() ([]byte, []int) { + return file_store_tag_proto_rawDescGZIP(), []int{0} +} + +func (x *Tag) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Tag) GetCreatorId() int32 { + if x != nil { + return x.CreatorId + } + return 0 +} + +var File_store_tag_proto protoreflect.FileDescriptor + +var file_store_tag_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0x38, + 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x42, 0x0e, 0x5a, 0x0c, 0x67, 0x65, 0x6e, 0x2d, + 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_store_tag_proto_rawDescOnce sync.Once + file_store_tag_proto_rawDescData = file_store_tag_proto_rawDesc +) + +func file_store_tag_proto_rawDescGZIP() []byte { + file_store_tag_proto_rawDescOnce.Do(func() { + file_store_tag_proto_rawDescData = protoimpl.X.CompressGZIP(file_store_tag_proto_rawDescData) + }) + return file_store_tag_proto_rawDescData +} + +var file_store_tag_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_store_tag_proto_goTypes = []interface{}{ + (*Tag)(nil), // 0: memos.store.Tag +} +var file_store_tag_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_store_tag_proto_init() } +func file_store_tag_proto_init() { + if File_store_tag_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_store_tag_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Tag); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_store_tag_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_store_tag_proto_goTypes, + DependencyIndexes: file_store_tag_proto_depIdxs, + MessageInfos: file_store_tag_proto_msgTypes, + }.Build() + File_store_tag_proto = out.File + file_store_tag_proto_rawDesc = nil + file_store_tag_proto_goTypes = nil + file_store_tag_proto_depIdxs = nil +} diff --git a/proto/store/tag.proto b/proto/store/tag.proto new file mode 100644 index 00000000..cf57422d --- /dev/null +++ b/proto/store/tag.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package memos.store; + +option go_package = "gen-go/store"; + +message Tag { + string name = 1; + int32 creator_id = 2; +}