├── .github └── workflows │ └── ci-workflow.yml ├── .gitignore ├── .mailmap ├── .travis.yml ├── AUTHORS ├── CONTRIBUTORS ├── GOLANG_CONTRIBUTORS ├── LICENSE ├── Makefile ├── README ├── Readme.md ├── bench.md ├── codec ├── codec.go └── codec_test.go ├── conformance ├── Makefile ├── conformance.go ├── conformance.sh ├── internal │ └── conformance_proto │ │ ├── conformance.pb.go │ │ └── conformance.proto └── test.sh ├── custom_types.md ├── extensions.md ├── go.mod ├── go.sum ├── gogoproto ├── Makefile ├── doc.go ├── gogo.pb.go ├── gogo.pb.golden ├── gogo.proto └── helper.go ├── gogoreplace └── main.go ├── install-protobuf.sh ├── io ├── full.go ├── io.go ├── io_test.go ├── uint32.go ├── uint32_test.go └── varint.go ├── jsonpb ├── jsonpb.go ├── jsonpb_test.go └── jsonpb_test_proto │ ├── Makefile │ ├── bytes.go │ ├── more_test_objects.pb.go │ ├── more_test_objects.proto │ ├── test_objects.pb.go │ └── test_objects.proto ├── plugin ├── compare │ ├── compare.go │ └── comparetest.go ├── defaultcheck │ └── defaultcheck.go ├── description │ ├── description.go │ └── descriptiontest.go ├── embedcheck │ └── embedcheck.go ├── enumstringer │ └── enumstringer.go ├── equal │ ├── equal.go │ └── equaltest.go ├── face │ ├── face.go │ └── facetest.go ├── gostring │ ├── gostring.go │ └── gostringtest.go ├── marshalto │ └── marshalto.go ├── oneofcheck │ └── oneofcheck.go ├── populate │ └── populate.go ├── size │ ├── size.go │ └── sizetest.go ├── stringer │ ├── stringer.go │ └── stringertest.go ├── testgen │ └── testgen.go ├── union │ ├── union.go │ └── uniontest.go └── unmarshal │ └── unmarshal.go ├── proto ├── Makefile ├── all_test.go ├── any_test.go ├── clone.go ├── clone_test.go ├── custom_gogo.go ├── decode.go ├── decode_test.go ├── deprecated.go ├── discard.go ├── discard_test.go ├── duration.go ├── duration_gogo.go ├── encode.go ├── encode_gogo.go ├── encode_test.go ├── equal.go ├── equal_test.go ├── extensions.go ├── extensions_gogo.go ├── extensions_test.go ├── lib.go ├── lib_gogo.go ├── map_test.go ├── message_set.go ├── message_set_test.go ├── pointer_reflect.go ├── pointer_reflect_gogo.go ├── pointer_unsafe.go ├── pointer_unsafe_gogo.go ├── properties.go ├── properties_gogo.go ├── proto3_proto │ ├── Makefile │ ├── proto3.pb.go │ └── proto3.proto ├── proto3_test.go ├── size2_test.go ├── size_test.go ├── skip_gogo.go ├── table_marshal.go ├── table_marshal_gogo.go ├── table_merge.go ├── table_unmarshal.go ├── table_unmarshal_gogo.go ├── test_proto │ ├── Makefile │ ├── test.pb.go │ └── test.proto ├── text.go ├── text_gogo.go ├── text_parser.go ├── text_parser_test.go ├── text_test.go ├── timestamp.go ├── timestamp_gogo.go ├── wrappers.go └── wrappers_gogo.go ├── protobuf ├── Makefile └── google │ └── protobuf │ ├── any.proto │ ├── api.proto │ ├── compiler │ └── plugin.proto │ ├── descriptor.proto │ ├── duration.proto │ ├── empty.proto │ ├── field_mask.proto │ ├── source_context.proto │ ├── struct.proto │ ├── timestamp.proto │ ├── type.proto │ └── wrappers.proto ├── protoc-gen-combo └── combo.go ├── protoc-gen-gofast └── main.go ├── protoc-gen-gogo ├── Makefile ├── descriptor │ ├── Makefile │ ├── descriptor.go │ ├── descriptor.pb.go │ ├── descriptor_gostring.gen.go │ ├── descriptor_test.go │ └── helper.go ├── doc.go ├── generator │ ├── generator.go │ ├── helper.go │ ├── internal │ │ └── remap │ │ │ ├── remap.go │ │ │ └── remap_test.go │ └── name_test.go ├── golden_test.go ├── gomobile │ └── gomobile.go ├── grpc │ └── grpc.go ├── main.go ├── plugin │ ├── Makefile │ └── plugin.pb.go └── testdata │ ├── Makefile │ ├── deprecated │ ├── deprecated.pb.go │ └── deprecated.proto │ ├── extension_base │ ├── extension_base.pb.go │ └── extension_base.proto │ ├── extension_extra │ ├── extension_extra.pb.go │ └── extension_extra.proto │ ├── extension_test.go │ ├── extension_user │ ├── extension_user.pb.go │ └── extension_user.proto │ ├── grpc │ ├── grpc.pb.go │ ├── grpc.proto │ ├── grpc_empty.pb.go │ └── grpc_empty.proto │ ├── import_public │ ├── a.pb.go │ ├── a.proto │ ├── b.pb.go │ ├── b.proto │ ├── importing │ │ ├── importing.pb.go │ │ └── importing.proto │ └── sub │ │ ├── a.pb.go │ │ ├── a.proto │ │ ├── b.pb.go │ │ └── b.proto │ ├── imports │ ├── fmt │ │ ├── m.pb.go │ │ └── m.proto │ ├── test_a_1 │ │ ├── m1.pb.go │ │ ├── m1.proto │ │ ├── m2.pb.go │ │ └── m2.proto │ ├── test_a_2 │ │ ├── m3.pb.go │ │ ├── m3.proto │ │ ├── m4.pb.go │ │ └── m4.proto │ ├── test_b_1 │ │ ├── m1.pb.go │ │ ├── m1.proto │ │ ├── m2.pb.go │ │ └── m2.proto │ ├── test_import_a1m1.pb.go │ ├── test_import_a1m1.proto │ ├── test_import_a1m2.pb.go │ ├── test_import_a1m2.proto │ ├── test_import_all.pb.go │ └── test_import_all.proto │ ├── main_test.go │ ├── multi │ ├── .gitignore │ ├── multi1.proto │ ├── multi2.proto │ └── multi3.proto │ ├── my_test │ ├── test.pb.go │ └── test.proto │ └── proto3 │ ├── proto3.pb.go │ └── proto3.proto ├── protoc-gen-gogofast └── main.go ├── protoc-gen-gogofaster └── main.go ├── protoc-gen-gogoslick └── main.go ├── protoc-gen-gogotypes └── main.go ├── protoc-gen-gostring └── main.go ├── protoc-min-version └── minversion.go ├── sortkeys └── sortkeys.go ├── test ├── .gitignore ├── Makefile ├── asymetric-issue125 │ ├── Makefile │ ├── asym.pb.go │ ├── asym.proto │ ├── asym_test.go │ └── pop.go ├── bug_test.go ├── cachedsize │ ├── Makefile │ ├── cachedsize.pb.go │ ├── cachedsize.proto │ └── cachedsize_test.go ├── casttype │ ├── Makefile │ ├── casttype.proto │ ├── combos │ │ ├── both │ │ │ ├── casttype.pb.go │ │ │ ├── casttype.proto │ │ │ └── casttypepb_test.go │ │ ├── marshaler │ │ │ ├── casttype.pb.go │ │ │ ├── casttype.proto │ │ │ └── casttypepb_test.go │ │ ├── neither │ │ │ ├── casttype.pb.go │ │ │ ├── casttype.proto │ │ │ └── casttypepb_test.go │ │ └── unmarshaler │ │ │ ├── casttype.pb.go │ │ │ ├── casttype.proto │ │ │ └── casttypepb_test.go │ └── mytypes.go ├── castvalue │ ├── Makefile │ ├── castvalue.pb.go │ ├── castvalue.proto │ ├── castvaluepb_test.go │ ├── combos │ │ ├── both │ │ │ ├── castvalue.pb.go │ │ │ ├── castvalue.proto │ │ │ ├── castvaluepb_test.go │ │ │ └── mytypes.go │ │ ├── marshaler │ │ │ ├── castvalue.pb.go │ │ │ ├── castvalue.proto │ │ │ ├── castvaluepb_test.go │ │ │ └── mytypes.go │ │ └── unmarshaler │ │ │ ├── castvalue.pb.go │ │ │ ├── castvalue.proto │ │ │ ├── castvaluepb_test.go │ │ │ └── mytypes.go │ └── mytypes.go ├── combos │ ├── both │ │ ├── bug_test.go │ │ ├── t.go │ │ ├── thetest.pb.go │ │ ├── thetest.proto │ │ ├── thetestpb_test.go │ │ └── uuid.go │ ├── marshaler │ │ ├── bug_test.go │ │ ├── t.go │ │ ├── thetest.pb.go │ │ ├── thetest.proto │ │ ├── thetestpb_test.go │ │ └── uuid.go │ └── unmarshaler │ │ ├── bug_test.go │ │ ├── t.go │ │ ├── thetest.pb.go │ │ ├── thetest.proto │ │ ├── thetestpb_test.go │ │ └── uuid.go ├── custom-dash-type │ └── customdash.go ├── custom │ ├── custom.go │ └── custom_test.go ├── custombytesnonstruct │ ├── Makefile │ ├── custombytesnonstruct_test.go │ ├── customtype.go │ ├── proto.pb.go │ └── proto.proto ├── dashfilename │ ├── dash-filename.proto │ ├── df_test.go │ └── doc.go ├── data │ ├── Makefile │ ├── data.pb.go │ ├── data.proto │ └── datapb_test.go ├── defaultconflict │ ├── df.proto │ ├── dg.proto │ ├── doc.go │ ├── nc.proto │ ├── nc_test.go │ ├── ne.proto │ └── nx.proto ├── deterministic │ ├── Makefile │ ├── deterministic.pb.go │ ├── deterministic.proto │ └── deterministic_test.go ├── embedconflict │ ├── .gitignore │ ├── doc.go │ ├── eb.proto │ ├── ec.proto │ ├── ec_test.go │ ├── ee.proto │ ├── em.proto │ ├── en.proto │ └── er.proto ├── empty-issue70 │ ├── Makefile │ ├── empty.pb.go │ ├── empty.proto │ └── empty_test.go ├── enumcustomname │ ├── Makefile │ ├── enumcustomname.pb.go │ └── enumcustomname.proto ├── enumdecl │ ├── Makefile │ ├── enumdecl.pb.go │ ├── enumdecl.proto │ ├── enumdeclpb_test.go │ └── models.go ├── enumdecl_all │ ├── Makefile │ ├── enumdeclall.pb.go │ ├── enumdeclall.proto │ ├── enumdeclallpb_test.go │ └── models.go ├── enumprefix │ ├── Makefile │ ├── enumprefix.pb.go │ └── enumprefix.proto ├── enumstringer │ ├── Makefile │ ├── enumstringer.pb.go │ ├── enumstringer.proto │ ├── enumstringerpb_test.go │ └── string.go ├── example │ ├── Makefile │ ├── example.pb.go │ ├── example.proto │ ├── example_test.go │ └── examplepb_test.go ├── extension_test.go ├── filedotname │ ├── Makefile │ ├── file.dot.pb.go │ ├── file.dot.proto │ └── file.dotpb_test.go ├── fuzztests │ ├── Makefile │ ├── fuzz.pb.go │ ├── fuzz.proto │ └── fuzz_test.go ├── group │ ├── Makefile │ ├── group.pb.go │ ├── group.proto │ └── grouppb_test.go ├── importcustom-issue389 │ ├── Makefile │ ├── imported │ │ ├── Makefile │ │ ├── a.pb.go │ │ ├── a.proto │ │ ├── apb_test.go │ │ └── b.go │ └── importing │ │ ├── Makefile │ │ ├── c.pb.go │ │ ├── c.proto │ │ └── cpb_test.go ├── importdedup │ ├── Makefile │ ├── importdedup_test.go │ ├── proto.pb.go │ ├── proto.proto │ └── subpkg │ │ ├── customtype.go │ │ ├── subproto.pb.go │ │ └── subproto.proto ├── importduplicate │ ├── Makefile │ ├── importduplicate.pb.go │ ├── importduplicate.proto │ ├── importduplicate_test.go │ ├── importduplicatepb_test.go │ ├── proto │ │ ├── proto.pb.go │ │ ├── proto.proto │ │ └── protopb_test.go │ └── sortkeys │ │ ├── sortable.pb.go │ │ ├── sortable.proto │ │ └── sortablepb_test.go ├── indeximport-issue72 │ ├── Makefile │ ├── index │ │ ├── index.pb.go │ │ ├── index.proto │ │ └── indexpb_test.go │ ├── indeximport.pb.go │ ├── indeximport.proto │ └── indeximportpb_test.go ├── int64support │ ├── Makefile │ ├── object.pb.go │ ├── object.proto │ ├── object_js.go │ ├── object_js_test.go │ └── objectpb_test.go ├── issue260 │ ├── Makefile │ ├── README.md │ ├── issue260.pb.go │ ├── issue260.proto │ ├── issue260pb_test.go │ └── models.go ├── issue261 │ ├── Makefile │ ├── issue261.pb.go │ └── issue261.proto ├── issue262 │ ├── Makefile │ ├── timefail.pb.go │ └── timefail.proto ├── issue270 │ ├── a │ │ ├── a1.proto │ │ └── a2.proto │ ├── b │ │ └── b.proto │ ├── doc.go │ └── issue270_test.go ├── issue312 │ ├── Makefile │ ├── events │ │ ├── Makefile │ │ ├── events.pb.go │ │ ├── events.proto │ │ └── eventspb_test.go │ ├── issue312.pb.go │ └── issue312.proto ├── issue322 │ ├── Makefile │ ├── issue322.pb.go │ ├── issue322.proto │ └── issue322pb_test.go ├── issue330 │ ├── Makefile │ ├── issue330.pb.go │ ├── issue330.proto │ ├── issue330pb_test.go │ └── type.go ├── issue34 │ ├── Makefile │ ├── issue34_test.go │ ├── proto.pb.go │ └── proto.proto ├── issue411 │ ├── Makefile │ ├── ids.go │ ├── ids_test.go │ ├── issue411.pb.go │ └── issue411.proto ├── issue427 │ ├── .gitignore │ ├── Makefile │ ├── README.md │ └── issue427.proto ├── issue42order │ ├── Makefile │ ├── issue42.pb.go │ ├── issue42.proto │ └── order_test.go ├── issue435 │ ├── Makefile │ ├── issue435.pb.go │ ├── issue435.proto │ └── issue435pb_test.go ├── issue438 │ ├── Makefile │ ├── issue438.pb.go │ └── issue438.proto ├── issue444 │ ├── Makefile │ ├── issue444.pb.go │ ├── issue444.proto │ └── issue444_test.go ├── issue449 │ ├── Makefile │ ├── issue449.pb.go │ ├── issue449.proto │ └── issue449_test.go ├── issue498 │ ├── Makefile │ ├── issue498.pb.go │ ├── issue498.proto │ └── issue498pb_test.go ├── issue503 │ ├── Makefile │ ├── issue503.pb.go │ ├── issue503.proto │ └── issue503_test.go ├── issue530 │ ├── Makefile │ ├── issue530.pb.go │ ├── issue530.proto │ ├── issue530_test.go │ └── issue530pb_test.go ├── issue617 │ ├── Makefile │ ├── issue617.pb.go │ └── issue617.proto ├── issue620 │ ├── Makefile │ ├── issue620.pb.go │ ├── issue620.proto │ └── issue620_test.go ├── issue630 │ ├── Makefile │ ├── issue630.pb.go │ ├── issue630.proto │ └── issue630_test.go ├── issue8 │ ├── Makefile │ ├── proto.pb.go │ ├── proto.proto │ └── protopb_test.go ├── jsonpb-gogo │ ├── jsonpb_gogo.go │ └── jsonpb_gogo_test.go ├── mapdefaults │ ├── Makefile │ ├── combos │ │ ├── both │ │ │ ├── map.pb.go │ │ │ ├── map.proto │ │ │ ├── map_test.go │ │ │ ├── mappb_test.go │ │ │ └── unknown_test.go │ │ ├── marshaler │ │ │ ├── map.pb.go │ │ │ ├── map.proto │ │ │ ├── map_test.go │ │ │ └── mappb_test.go │ │ ├── neither │ │ │ ├── map.pb.go │ │ │ ├── map.proto │ │ │ ├── map_test.go │ │ │ └── mappb_test.go │ │ └── unmarshaler │ │ │ ├── map.pb.go │ │ │ ├── map.proto │ │ │ ├── map_test.go │ │ │ ├── mappb_test.go │ │ │ └── unknown_test.go │ ├── map.pb.go │ ├── map.proto │ ├── map_test.go.in │ └── unknown_test.go.in ├── mapsproto2 │ ├── Makefile │ ├── combos │ │ ├── both │ │ │ ├── mapsproto2.pb.go │ │ │ ├── mapsproto2.proto │ │ │ ├── mapsproto2_test.go │ │ │ └── mapsproto2pb_test.go │ │ ├── marshaler │ │ │ ├── mapsproto2.pb.go │ │ │ ├── mapsproto2.proto │ │ │ ├── mapsproto2_test.go │ │ │ └── mapsproto2pb_test.go │ │ ├── neither │ │ │ ├── mapsproto2.pb.go │ │ │ ├── mapsproto2.proto │ │ │ ├── mapsproto2_test.go │ │ │ └── mapsproto2pb_test.go │ │ └── unmarshaler │ │ │ ├── mapsproto2.pb.go │ │ │ ├── mapsproto2.proto │ │ │ ├── mapsproto2_test.go │ │ │ └── mapsproto2pb_test.go │ ├── doc.go │ ├── header.proto │ ├── mapsproto2.proto │ └── mapsproto2_test.go.in ├── merge │ ├── Makefile │ ├── merge.pb.go │ ├── merge.proto │ └── merge_test.go ├── mixbench │ ├── .gitignore │ ├── marshal.txt │ ├── marshaler.txt │ ├── mixbench.go │ ├── oldmarshaler.txt │ ├── oldunmarshaler.txt │ ├── unmarshal.txt │ ├── unmarshaler.txt │ ├── unsafe_marshaler.txt │ └── unsafe_unmarshaler.txt ├── moredefaults │ ├── Makefile │ ├── md.pb.go │ ├── md.proto │ ├── md_test.go │ └── mdpb_test.go ├── nopackage │ ├── Makefile │ ├── nopackage.pb.go │ ├── nopackage.proto │ └── nopackage_test.go ├── oneof │ ├── Makefile │ ├── combos │ │ ├── both │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ │ ├── marshaler │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ │ ├── neither │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ │ └── unmarshaler │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ ├── doc.go │ └── one.proto ├── oneof3 │ ├── Makefile │ ├── combos │ │ ├── both │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ │ ├── marshaler │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ │ ├── neither │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ │ └── unmarshaler │ │ │ ├── one.pb.go │ │ │ ├── one.proto │ │ │ └── onepb_test.go │ ├── doc.go │ └── one.proto ├── oneofembed │ ├── Makefile │ ├── oneofembed.pb.go │ ├── oneofembed.proto │ └── oneofembedpb_test.go ├── packed │ ├── Makefile │ ├── doc.go │ ├── packed.pb.go │ ├── packed.proto │ └── packed_test.go ├── proto3extension │ ├── Makefile │ ├── proto3ext.pb.go │ └── proto3ext.proto ├── protobuffer │ ├── Makefile │ ├── protobuffer.pb.go │ ├── protobuffer.proto │ └── protobuffer_test.go ├── protosize │ ├── Makefile │ ├── protosize.pb.go │ ├── protosize.proto │ ├── protosize_test.go │ └── protosizepb_test.go ├── registration │ ├── .gitignore │ ├── Makefile │ ├── registration.proto │ └── registration_test.go.in ├── required │ ├── Makefile │ ├── requiredexample.pb.go │ ├── requiredexample.proto │ └── requiredexamplepb_test.go ├── setextensionbytes │ ├── Makefile │ ├── setextensionbytes.pb.go │ ├── setextensionbytes.proto │ └── setextensionbytes_test.go ├── sizerconflict │ ├── doc.go │ ├── sizerconflict.proto │ └── sizerconflict_test.go ├── sizeunderscore │ ├── Makefile │ ├── sizeunderscore.pb.go │ ├── sizeunderscore.proto │ └── sizeunderscorepb_test.go ├── stdtypes │ ├── Makefile │ ├── concurrency_test.go │ ├── stdtypes.pb.go │ ├── stdtypes.proto │ └── stdtypespb_test.go ├── t.go ├── tags │ ├── Makefile │ ├── doc.go │ ├── tags.pb.go │ ├── tags.proto │ └── tags_test.go ├── theproto3 │ ├── Makefile │ ├── combos │ │ ├── both │ │ │ ├── proto3_test.go │ │ │ ├── theproto3.pb.go │ │ │ ├── theproto3.proto │ │ │ └── theproto3pb_test.go │ │ ├── marshaler │ │ │ ├── proto3_test.go │ │ │ ├── theproto3.pb.go │ │ │ ├── theproto3.proto │ │ │ └── theproto3pb_test.go │ │ ├── neither │ │ │ ├── proto3_test.go │ │ │ ├── theproto3.pb.go │ │ │ ├── theproto3.proto │ │ │ └── theproto3pb_test.go │ │ └── unmarshaler │ │ │ ├── proto3_test.go │ │ │ ├── theproto3.pb.go │ │ │ ├── theproto3.proto │ │ │ └── theproto3pb_test.go │ ├── doc.go │ ├── footer.proto │ ├── header.proto │ ├── maps.proto │ ├── proto3_test.go.in │ └── theproto3.proto ├── thetest.pb.go ├── thetest.proto ├── thetestpb_test.go ├── typedecl │ ├── Makefile │ ├── models.go │ ├── typedecl.pb.go │ ├── typedecl.proto │ └── typedeclpb_test.go ├── typedecl_all │ ├── Makefile │ ├── models.go │ ├── typedeclall.pb.go │ ├── typedeclall.proto │ └── typedeclallpb_test.go ├── typedeclimport │ ├── Makefile │ ├── models.go │ ├── subpkg │ │ ├── subpkg.pb.go │ │ └── subpkg.proto │ ├── typedeclimport.pb.go │ ├── typedeclimport.proto │ └── typedeclimport_test.go ├── types │ ├── Makefile │ ├── combos │ │ ├── both │ │ │ ├── types.pb.go │ │ │ ├── types.proto │ │ │ ├── types_test.go │ │ │ └── typespb_test.go │ │ ├── marshaler │ │ │ ├── types.pb.go │ │ │ ├── types.proto │ │ │ ├── types_test.go │ │ │ └── typespb_test.go │ │ ├── neither │ │ │ ├── types.pb.go │ │ │ ├── types.proto │ │ │ ├── types_test.go │ │ │ └── typespb_test.go │ │ └── unmarshaler │ │ │ ├── types.pb.go │ │ │ ├── types.proto │ │ │ ├── types_test.go │ │ │ └── typespb_test.go │ ├── types.proto │ └── types_test.go.in ├── unmarshalmerge │ ├── Makefile │ ├── unmarshalmerge.pb.go │ ├── unmarshalmerge.proto │ ├── unmarshalmerge_test.go │ └── unmarshalmergepb_test.go ├── unrecognized │ ├── Makefile │ ├── oldnew_test.go │ ├── unrecognized.pb.go │ ├── unrecognized.proto │ └── unrecognizedpb_test.go ├── unrecognizedgroup │ ├── Makefile │ ├── oldnew_test.go │ ├── unrecognizedgroup.pb.go │ ├── unrecognizedgroup.proto │ └── unrecognizedgrouppb_test.go ├── uuid.go ├── uuid_test.go └── xxxfields │ ├── Makefile │ ├── xxxfields.pb.go │ ├── xxxfields.proto │ └── xxxfieldspb_test.go ├── types ├── any.go ├── any.pb.go ├── any_test.go ├── api.pb.go ├── doc.go ├── duration.go ├── duration.pb.go ├── duration_gogo.go ├── duration_test.go ├── empty.pb.go ├── field_mask.pb.go ├── protosize.go ├── source_context.pb.go ├── struct.pb.go ├── timestamp.go ├── timestamp.pb.go ├── timestamp_gogo.go ├── timestamp_test.go ├── type.pb.go ├── wrappers.pb.go └── wrappers_gogo.go ├── vanity ├── command │ └── command.go ├── enum.go ├── field.go ├── file.go ├── foreach.go ├── msg.go └── test │ ├── Makefile │ ├── doc.go │ ├── fast │ ├── gogovanity.pb.go │ ├── proto3.pb.go │ └── vanity.pb.go │ ├── faster │ ├── gogovanity.pb.go │ ├── proto3.pb.go │ └── vanity.pb.go │ ├── gofast │ └── .gitignore │ ├── gogovanity.proto │ ├── proto3.proto │ ├── slick │ ├── gogovanity.pb.go │ ├── proto3.pb.go │ └── vanity.pb.go │ ├── vanity.proto │ └── vanity_test.go └── version └── version.go /.github/workflows/ci-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | on: 3 | push: 4 | branches: 5 | - ghworkflow 6 | pull_request: 7 | branches: 8 | - master 9 | 10 | jobs: 11 | build_and_test: 12 | name: go ${{ matrix.go_version }} - pb-${{ matrix.protobuf_version }} 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | go_version: [1.15.x, 1.12.x] 17 | protobuf_version: [3.14.0, 3.0.2, 2.6.1] 18 | fail-fast: false 19 | steps: 20 | - name: Checkout branch 21 | uses: actions/checkout@v1 22 | with: 23 | path: gopath/src/github.com/gogo/protobuf 24 | fetch-depth: 5 25 | 26 | - name: Setup go 27 | uses: actions/setup-go@v1 28 | with: 29 | go-version: ${{ matrix.go_version }} 30 | 31 | - name: Setup protoc 32 | env: 33 | PROTOBUF_VERSION: ${{ matrix.protobuf_version }} 34 | run: ./install-protobuf.sh 35 | 36 | - name: Protoc version 37 | run: PATH=$HOME/bin:$PATH protoc --version 38 | - name: env 39 | run: env && go env && pwd 40 | 41 | - name: Build server all 42 | run: GOPATH=/home/runner/work/protobuf/gopath GOBIN=$GOPATH/bin PATH=$HOME/bin:$GOBIN:$PATH make buildserverall 43 | 44 | - name: Diff check 45 | if: matrix.protobuf_version == '3.14.0' && matrix.go_version == '1.15.x' 46 | run: (! git status --porcelain | read || (git status; git diff; exit 1)) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ._* 2 | *.js 3 | *.js.map 4 | 5 | # Conformance test output and transient files. 6 | conformance/failing_tests.txt -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Walter Schulze Walter Schulze 2 | Walter Schulze 3 | Walter Schulze awalterschulze 4 | Walter Schulze awalterschulze@gmail.com 5 | John Tuley 6 | Anton Povarov 7 | Denis Smirnov dennwc 8 | DongYun Kang -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | apt: 2 | update: true 3 | 4 | env: 5 | - PROTOBUF_VERSION=2.6.1 6 | - PROTOBUF_VERSION=3.0.2 7 | - PROTOBUF_VERSION=3.14.0 8 | 9 | before_install: 10 | - HOME=/home/travis ./install-protobuf.sh 11 | - PATH=/home/travis/bin:$PATH protoc --version 12 | 13 | script: 14 | - PATH=/home/travis/bin:$PATH make buildserverall 15 | - echo $TRAVIS_GO_VERSION 16 | - if [[ "$PROTOBUF_VERSION" == "3.14.0" ]] && [[ "$TRAVIS_GO_VERSION" == "1.15.x" ]]; then ! git status --porcelain | read || (git status; git diff; exit 1); fi 17 | 18 | language: go 19 | 20 | go: 21 | - 1.12.x 22 | - 1.15.x 23 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of GoGo authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS file, which 3 | # lists people. For example, employees are listed in CONTRIBUTORS, 4 | # but not in AUTHORS, because the employer holds the copyright. 5 | 6 | # Names should be added to this file as one of 7 | # Organization's name 8 | # Individual's name 9 | # Individual's name 10 | 11 | # Please keep the list sorted. 12 | 13 | Sendgrid, Inc 14 | Vastech SA (PTY) LTD 15 | Walter Schulze 16 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Anton Povarov 2 | Brian Goff 3 | Clayton Coleman 4 | Denis Smirnov 5 | DongYun Kang 6 | Dwayne Schultz 7 | Georg Apitz 8 | Gustav Paul 9 | Johan Brandhorst 10 | John Shahid 11 | John Tuley 12 | Laurent 13 | Patrick Lee 14 | Peter Edge 15 | Roger Johansson 16 | Sam Nguyen 17 | Sergio Arbeo 18 | Stephen J Day 19 | Tamir Duberstein 20 | Todd Eisenberger 21 | Tormod Erevik Lea 22 | Vyacheslav Kim 23 | Walter Schulze 24 | -------------------------------------------------------------------------------- /GOLANG_CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | The contributors to the Go protobuf repository: 2 | 3 | # This source code was written by the Go contributors. 4 | # The master list of contributors is in the main Go distribution, 5 | # visible at http://tip.golang.org/CONTRIBUTORS. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, The GoGo Authors. All rights reserved. 2 | 3 | Protocol Buffers for Go with Gadgets 4 | 5 | Go support for Protocol Buffers - Google's data interchange format 6 | 7 | Copyright 2010 The Go Authors. All rights reserved. 8 | https://github.com/golang/protobuf 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are 12 | met: 13 | 14 | * Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the following disclaimer 18 | in the documentation and/or other materials provided with the 19 | distribution. 20 | * Neither the name of Google Inc. nor the names of its 21 | contributors may be used to endorse or promote products derived from 22 | this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | 36 | -------------------------------------------------------------------------------- /conformance/conformance.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd $(dirname $0) 4 | exec go run conformance.go $* -------------------------------------------------------------------------------- /conformance/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROTOBUF_ROOT=$1 4 | CONFORMANCE_ROOT=$1/conformance 5 | CONFORMANCE_TEST_RUNNER=$CONFORMANCE_ROOT/conformance-test-runner 6 | 7 | cd $(dirname $0) 8 | 9 | if [[ $PROTOBUF_ROOT == "" ]]; then 10 | echo "usage: test.sh " >/dev/stderr 11 | exit 1 12 | fi 13 | 14 | if [[ ! -x $CONFORMANCE_TEST_RUNNER ]]; then 15 | echo "SKIP: conformance test runner not installed" >/dev/stderr 16 | exit 0 17 | fi 18 | 19 | a=$CONFORMANCE_ROOT/conformance.proto 20 | b=internal/conformance_proto/conformance.proto 21 | if [[ $(diff $a $b) != "" ]]; then 22 | cp $a $b 23 | echo "WARNING: conformance.proto is out of date" >/dev/stderr 24 | fi 25 | 26 | $CONFORMANCE_TEST_RUNNER --failure_list failure_list_go.txt ./conformance.sh 27 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gogo/protobuf 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/kisielk/errcheck v1.5.0 // indirect 7 | github.com/kisielk/gotool v1.0.0 // indirect 8 | golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect 9 | ) 10 | -------------------------------------------------------------------------------- /gogoproto/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:../../../../ --proto_path=../../../../:../protobuf/:. *.proto 32 | 33 | restore: 34 | cp gogo.pb.golden gogo.pb.go 35 | 36 | preserve: 37 | cp gogo.pb.go gogo.pb.golden 38 | -------------------------------------------------------------------------------- /gogoproto/gogo.pb.golden: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: gogo.proto 3 | // DO NOT EDIT! 4 | 5 | package gogoproto 6 | 7 | import proto "github.com/gogo/protobuf/proto" 8 | import json "encoding/json" 9 | import math "math" 10 | import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" 11 | 12 | // Reference proto, json, and math imports to suppress error if they are not otherwise used. 13 | var _ = proto.Marshal 14 | var _ = &json.SyntaxError{} 15 | var _ = math.Inf 16 | 17 | var E_Nullable = &proto.ExtensionDesc{ 18 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 19 | ExtensionType: (*bool)(nil), 20 | Field: 51235, 21 | Name: "gogoproto.nullable", 22 | Tag: "varint,51235,opt,name=nullable", 23 | } 24 | 25 | var E_Embed = &proto.ExtensionDesc{ 26 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 27 | ExtensionType: (*bool)(nil), 28 | Field: 51236, 29 | Name: "gogoproto.embed", 30 | Tag: "varint,51236,opt,name=embed", 31 | } 32 | 33 | var E_Customtype = &proto.ExtensionDesc{ 34 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 35 | ExtensionType: (*string)(nil), 36 | Field: 51237, 37 | Name: "gogoproto.customtype", 38 | Tag: "bytes,51237,opt,name=customtype", 39 | } 40 | 41 | func init() { 42 | proto.RegisterExtension(E_Nullable) 43 | proto.RegisterExtension(E_Embed) 44 | proto.RegisterExtension(E_Customtype) 45 | } 46 | -------------------------------------------------------------------------------- /gogoreplace/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io/ioutil" 7 | "os" 8 | ) 9 | 10 | func main() { 11 | args := os.Args 12 | if len(args) != 4 { 13 | fmt.Println("gogoreplace wants three arguments") 14 | fmt.Println(" gogoreplace oldsubstring newsubstring filename") 15 | os.Exit(1) 16 | } 17 | data, err := ioutil.ReadFile(args[3]) 18 | if err != nil { 19 | panic(err) 20 | } 21 | data = bytes.Replace(data, []byte(args[1]), []byte(args[2]), -1) 22 | if err := ioutil.WriteFile(args[3], data, 0666); err != nil { 23 | panic(err) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /install-protobuf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | die() { 6 | echo "$@" >&2 7 | exit 1 8 | } 9 | 10 | cd ${HOME} 11 | 12 | case "$PROTOBUF_VERSION" in 13 | 2*) 14 | basename=protobuf-$PROTOBUF_VERSION 15 | wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename.tar.gz 16 | tar xzf $basename.tar.gz 17 | cd protobuf-$PROTOBUF_VERSION 18 | ./configure --prefix=${HOME} && make -j2 && make install 19 | ;; 20 | 3*) 21 | basename=protoc-$PROTOBUF_VERSION-linux-x86_64 22 | wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename.zip 23 | unzip $basename.zip 24 | ;; 25 | *) 26 | die "unknown protobuf version: $PROTOBUF_VERSION" 27 | ;; 28 | esac 29 | -------------------------------------------------------------------------------- /jsonpb/jsonpb_test_proto/bytes.go: -------------------------------------------------------------------------------- 1 | package jsonpb 2 | 3 | // Byte is used to test that []byte type aliases are serialized to base64. 4 | type Byte byte 5 | 6 | // Bytes is used to test that []byte type aliases are serialized to base64. 7 | type Bytes []Byte 8 | -------------------------------------------------------------------------------- /proto/custom_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package proto 30 | 31 | import "reflect" 32 | 33 | type custom interface { 34 | Marshal() ([]byte, error) 35 | Unmarshal(data []byte) error 36 | Size() int 37 | } 38 | 39 | var customType = reflect.TypeOf((*custom)(nil)).Elem() 40 | -------------------------------------------------------------------------------- /proto/encode_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package proto 30 | 31 | func NewRequiredNotSetError(field string) *RequiredNotSetError { 32 | return &RequiredNotSetError{field} 33 | } 34 | -------------------------------------------------------------------------------- /proto/properties_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package proto 30 | 31 | import ( 32 | "reflect" 33 | ) 34 | 35 | var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem() 36 | var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem() 37 | -------------------------------------------------------------------------------- /proto/proto3_proto/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-min-version 3 | protoc-min-version --version="3.0.0" --gogo_out=\ 4 | Mtest_proto/test.proto=github.com/gogo/protobuf/proto/test_proto,\ 5 | Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. \ 6 | --proto_path=../../protobuf:../:. proto3.proto 7 | 8 | -------------------------------------------------------------------------------- /protoc-gen-gogo/descriptor/descriptor_test.go: -------------------------------------------------------------------------------- 1 | package descriptor_test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | tpb "github.com/gogo/protobuf/proto/test_proto" 8 | "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" 9 | ) 10 | 11 | func TestMessage(t *testing.T) { 12 | var msg *descriptor.DescriptorProto 13 | fd, md := descriptor.ForMessage(msg) 14 | if pkg, want := fd.GetPackage(), "google.protobuf"; pkg != want { 15 | t.Errorf("descriptor.ForMessage(%T).GetPackage() = %q; want %q", msg, pkg, want) 16 | } 17 | if name, want := md.GetName(), "DescriptorProto"; name != want { 18 | t.Fatalf("descriptor.ForMessage(%T).GetName() = %q; want %q", msg, name, want) 19 | } 20 | } 21 | 22 | func Example_options() { 23 | var msg *tpb.MyMessageSet 24 | _, md := descriptor.ForMessage(msg) 25 | if md.GetOptions().GetMessageSetWireFormat() { 26 | fmt.Printf("%v uses option message_set_wire_format.\n", md.GetName()) 27 | } 28 | 29 | // Output: 30 | // MyMessageSet uses option message_set_wire_format. 31 | } 32 | -------------------------------------------------------------------------------- /protoc-gen-gogo/testdata/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | all: test 33 | 34 | test: 35 | go test 36 | -------------------------------------------------------------------------------- /protoc-gen-gogo/testdata/multi/.gitignore: -------------------------------------------------------------------------------- 1 | *.pb.go 2 | -------------------------------------------------------------------------------- /protoc-gen-gostring/main.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package main 30 | 31 | import ( 32 | "github.com/gogo/protobuf/plugin/gostring" 33 | "github.com/gogo/protobuf/vanity/command" 34 | ) 35 | 36 | func main() { 37 | req := command.Read() 38 | p := gostring.NewGoString() 39 | p.Overwrite() 40 | resp := command.GeneratePlugin(req, p, "_gostring.gen.go") 41 | command.Write(resp) 42 | } 43 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | *.dat 2 | -------------------------------------------------------------------------------- /test/asymetric-issue125/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. asym.proto) 31 | -------------------------------------------------------------------------------- /test/asymetric-issue125/asym_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package asym 30 | 31 | import ( 32 | "testing" 33 | ) 34 | 35 | func TestAsym(t *testing.T) { 36 | m := &M{Arr: []MyType{{}, {}}} 37 | if err := m.VerboseEqual(m); err != nil { 38 | t.Fatalf("should be equal: %v", err) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/cachedsize/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. cachedsize.proto) 31 | -------------------------------------------------------------------------------- /test/casttype/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-combo 31 | go install github.com/gogo/protobuf/protoc-gen-gogo 32 | protoc-gen-combo --gogo_out=. --version="3.0.0" --proto_path=../../protobuf/:../../../../../:. casttype.proto 33 | -------------------------------------------------------------------------------- /test/castvalue/combos/both/mytypes.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package castvalue 30 | 31 | type MyWilson Wilson 32 | -------------------------------------------------------------------------------- /test/castvalue/combos/marshaler/mytypes.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package castvalue 30 | 31 | type MyWilson Wilson 32 | -------------------------------------------------------------------------------- /test/castvalue/combos/unmarshaler/mytypes.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package castvalue 30 | 31 | type MyWilson Wilson 32 | -------------------------------------------------------------------------------- /test/castvalue/mytypes.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package castvalue 30 | 31 | type MyWilson Wilson 32 | -------------------------------------------------------------------------------- /test/combos/both/t.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/gogo/protobuf/proto" 8 | ) 9 | 10 | type T struct { 11 | Data string 12 | } 13 | 14 | func (gt *T) protoType() *ProtoType { 15 | return &ProtoType{ 16 | Field2: >.Data, 17 | } 18 | } 19 | 20 | func (gt T) Equal(other T) bool { 21 | return gt.protoType().Equal(other.protoType()) 22 | } 23 | 24 | func (gt *T) Size() int { 25 | proto := &ProtoType{ 26 | Field2: >.Data, 27 | } 28 | return proto.Size() 29 | } 30 | 31 | func NewPopulatedT(r randyThetest) *T { 32 | data := NewPopulatedProtoType(r, false).Field2 33 | gt := &T{} 34 | if data != nil { 35 | gt.Data = *data 36 | } 37 | return gt 38 | } 39 | 40 | func (r T) Marshal() ([]byte, error) { 41 | return proto.Marshal(r.protoType()) 42 | } 43 | 44 | func (r *T) MarshalTo(data []byte) (n int, err error) { 45 | return r.protoType().MarshalTo(data) 46 | } 47 | 48 | func (r *T) Unmarshal(data []byte) error { 49 | pr := &ProtoType{} 50 | err := proto.Unmarshal(data, pr) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | if pr.Field2 != nil { 56 | r.Data = *pr.Field2 57 | } 58 | return nil 59 | } 60 | 61 | func (gt T) MarshalJSON() ([]byte, error) { 62 | return json.Marshal(gt.Data) 63 | } 64 | 65 | func (gt *T) UnmarshalJSON(data []byte) error { 66 | var s string 67 | err := json.Unmarshal(data, &s) 68 | if err != nil { 69 | return err 70 | } 71 | *gt = T{Data: s} 72 | return nil 73 | } 74 | 75 | func (gt T) Compare(other T) int { 76 | return strings.Compare(gt.Data, other.Data) 77 | } 78 | -------------------------------------------------------------------------------- /test/combos/marshaler/t.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/gogo/protobuf/proto" 8 | ) 9 | 10 | type T struct { 11 | Data string 12 | } 13 | 14 | func (gt *T) protoType() *ProtoType { 15 | return &ProtoType{ 16 | Field2: >.Data, 17 | } 18 | } 19 | 20 | func (gt T) Equal(other T) bool { 21 | return gt.protoType().Equal(other.protoType()) 22 | } 23 | 24 | func (gt *T) Size() int { 25 | proto := &ProtoType{ 26 | Field2: >.Data, 27 | } 28 | return proto.Size() 29 | } 30 | 31 | func NewPopulatedT(r randyThetest) *T { 32 | data := NewPopulatedProtoType(r, false).Field2 33 | gt := &T{} 34 | if data != nil { 35 | gt.Data = *data 36 | } 37 | return gt 38 | } 39 | 40 | func (r T) Marshal() ([]byte, error) { 41 | return proto.Marshal(r.protoType()) 42 | } 43 | 44 | func (r *T) MarshalTo(data []byte) (n int, err error) { 45 | return r.protoType().MarshalTo(data) 46 | } 47 | 48 | func (r *T) Unmarshal(data []byte) error { 49 | pr := &ProtoType{} 50 | err := proto.Unmarshal(data, pr) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | if pr.Field2 != nil { 56 | r.Data = *pr.Field2 57 | } 58 | return nil 59 | } 60 | 61 | func (gt T) MarshalJSON() ([]byte, error) { 62 | return json.Marshal(gt.Data) 63 | } 64 | 65 | func (gt *T) UnmarshalJSON(data []byte) error { 66 | var s string 67 | err := json.Unmarshal(data, &s) 68 | if err != nil { 69 | return err 70 | } 71 | *gt = T{Data: s} 72 | return nil 73 | } 74 | 75 | func (gt T) Compare(other T) int { 76 | return strings.Compare(gt.Data, other.Data) 77 | } 78 | -------------------------------------------------------------------------------- /test/combos/unmarshaler/t.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/gogo/protobuf/proto" 8 | ) 9 | 10 | type T struct { 11 | Data string 12 | } 13 | 14 | func (gt *T) protoType() *ProtoType { 15 | return &ProtoType{ 16 | Field2: >.Data, 17 | } 18 | } 19 | 20 | func (gt T) Equal(other T) bool { 21 | return gt.protoType().Equal(other.protoType()) 22 | } 23 | 24 | func (gt *T) Size() int { 25 | proto := &ProtoType{ 26 | Field2: >.Data, 27 | } 28 | return proto.Size() 29 | } 30 | 31 | func NewPopulatedT(r randyThetest) *T { 32 | data := NewPopulatedProtoType(r, false).Field2 33 | gt := &T{} 34 | if data != nil { 35 | gt.Data = *data 36 | } 37 | return gt 38 | } 39 | 40 | func (r T) Marshal() ([]byte, error) { 41 | return proto.Marshal(r.protoType()) 42 | } 43 | 44 | func (r *T) Unmarshal(data []byte) error { 45 | pr := &ProtoType{} 46 | err := proto.Unmarshal(data, pr) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | if pr.Field2 != nil { 52 | r.Data = *pr.Field2 53 | } 54 | return nil 55 | } 56 | 57 | func (gt T) MarshalJSON() ([]byte, error) { 58 | return json.Marshal(gt.Data) 59 | } 60 | 61 | func (gt *T) UnmarshalJSON(data []byte) error { 62 | var s string 63 | err := json.Unmarshal(data, &s) 64 | if err != nil { 65 | return err 66 | } 67 | *gt = T{Data: s} 68 | return nil 69 | } 70 | 71 | func (gt T) Compare(other T) int { 72 | return strings.Compare(gt.Data, other.Data) 73 | } 74 | -------------------------------------------------------------------------------- /test/custombytesnonstruct/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. proto.proto) 31 | -------------------------------------------------------------------------------- /test/custombytesnonstruct/custombytesnonstruct_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package custombytesnonstruct 30 | 31 | import testing "testing" 32 | 33 | func TestCustomBytesNonStruct(t *testing.T) { 34 | } 35 | -------------------------------------------------------------------------------- /test/custombytesnonstruct/customtype.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package custombytesnonstruct 30 | 31 | type CustomType int 32 | 33 | func (c *CustomType) Unmarshal(data []byte) error { 34 | data[0] = 42 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /test/dashfilename/dash-filename.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package dashfilename; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | option (gogoproto.marshaler_all) = true; 35 | 36 | message test { 37 | 38 | } 39 | -------------------------------------------------------------------------------- /test/dashfilename/doc.go: -------------------------------------------------------------------------------- 1 | package dashfilename 2 | -------------------------------------------------------------------------------- /test/data/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-min-version 31 | go install github.com/gogo/protobuf/protoc-gen-gogo 32 | protoc-min-version --version="3.0.0" --gogo_out=. \ 33 | --proto_path=../../../../../:../../protobuf/:. data.proto 34 | -------------------------------------------------------------------------------- /test/defaultconflict/df.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package defaultcheck; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | option (gogoproto.face_all) = true; 35 | option (gogoproto.goproto_getters_all) = false; 36 | 37 | message A { 38 | optional int64 Field1 = 1 [default=1234]; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /test/defaultconflict/dg.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package defaultcheck; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | option (gogoproto.goproto_getters_all) = false; 35 | 36 | message A { 37 | optional int64 Field1 = 1 [default=1234]; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /test/defaultconflict/doc.go: -------------------------------------------------------------------------------- 1 | package defaultcheck 2 | -------------------------------------------------------------------------------- /test/defaultconflict/nc.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package defaultcheck; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | message A { 35 | optional int64 Field1 = 1 [default = 1234, (gogoproto.nullable) = false];; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /test/defaultconflict/ne.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package defaultcheck; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | enum E { 35 | P = 10; 36 | Q = 11; 37 | } 38 | 39 | message A { 40 | optional E Field1 = 1 [(gogoproto.nullable) = false]; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /test/defaultconflict/nx.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package defaultcheck; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | message A { 35 | extensions 1 to max; 36 | } 37 | 38 | extend A { 39 | optional int64 Field1 = 1 [(gogoproto.nullable) = false]; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /test/deterministic/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-min-version 31 | protoc-min-version --version="3.0.0" --gogo_out=:. \ 32 | --proto_path=../../../../../:../../protobuf/:. deterministic.proto -------------------------------------------------------------------------------- /test/embedconflict/.gitignore: -------------------------------------------------------------------------------- 1 | *.pb.go 2 | -------------------------------------------------------------------------------- /test/embedconflict/doc.go: -------------------------------------------------------------------------------- 1 | package embedconflict 2 | -------------------------------------------------------------------------------- /test/embedconflict/eb.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | 31 | package embedconflict; 32 | 33 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 34 | 35 | message TakesLongTooDebug { 36 | optional bytes Field1 = 1; 37 | optional bytes Field2 = 2 [(gogoproto.nullable)=false, (gogoproto.embed)=true]; 38 | } 39 | -------------------------------------------------------------------------------- /test/embedconflict/ec.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package embedconflict; 30 | 31 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 32 | 33 | message A { 34 | optional int64 Field1 = 1; 35 | optional B B = 2 [(gogoproto.embed) = true]; 36 | } 37 | 38 | message B { 39 | optional double Field1 = 1; 40 | } 41 | -------------------------------------------------------------------------------- /test/embedconflict/ee.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package embedconflict; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | message E { 35 | optional int64 Field1 = 1; 36 | extensions 100 to 199; 37 | } 38 | 39 | extend E { 40 | optional int64 Field1 = 100 [(gogoproto.embed) = true]; 41 | } 42 | -------------------------------------------------------------------------------- /test/embedconflict/em.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package embedconflict; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | message C { 35 | optional int64 Field1 = 1; 36 | optional D D = 2 [(gogoproto.embed) = true]; 37 | } 38 | 39 | message D { 40 | option (gogoproto.marshaler) = true; 41 | optional double Field2 = 2; 42 | } 43 | -------------------------------------------------------------------------------- /test/embedconflict/en.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package embedconflict; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | message F { 35 | optional G G = 2 [(gogoproto.embed) = true, (gogoproto.customname) = "G"]; 36 | } 37 | 38 | message G { 39 | optional int64 Field1 = 1; 40 | } 41 | -------------------------------------------------------------------------------- /test/embedconflict/er.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package embedconflict; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | message A { 35 | optional int64 Field1 = 1; 36 | repeated B B = 2 [(gogoproto.embed) = true]; 37 | } 38 | 39 | message B { 40 | optional double Field2 = 2; 41 | } 42 | -------------------------------------------------------------------------------- /test/empty-issue70/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. empty.proto) 31 | -------------------------------------------------------------------------------- /test/empty-issue70/empty.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax="proto2"; 30 | 31 | package empty; 32 | 33 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 34 | 35 | option (gogoproto.unmarshaler_all) = true; 36 | 37 | message TestRequest { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /test/empty-issue70/empty_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package empty 30 | 31 | import ( 32 | "testing" 33 | ) 34 | 35 | func TestEmpty(t *testing.T) { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /test/enumcustomname/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. enumcustomname.proto) 31 | -------------------------------------------------------------------------------- /test/enumdecl/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. enumdecl.proto 4 | -------------------------------------------------------------------------------- /test/enumdecl/enumdecl.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package enumdecl; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.testgen_all) = true; 8 | option (gogoproto.populate_all) = true; 9 | option (gogoproto.benchgen_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.marshaler_all) = true; 12 | option (gogoproto.sizer_all) = true; 13 | option (gogoproto.equal_all) = true; 14 | option (gogoproto.verbose_equal_all) = true; 15 | option (gogoproto.unsafe_marshaler_all) = false; 16 | option (gogoproto.unsafe_unmarshaler_all) = false; 17 | 18 | enum MyEnum { 19 | option (gogoproto.enumdecl) = false; 20 | option (gogoproto.goproto_enum_prefix) = false; 21 | A = 0; 22 | B = 1; 23 | } 24 | 25 | message Message { 26 | MyEnum enumerated_field = 1; 27 | } 28 | -------------------------------------------------------------------------------- /test/enumdecl/models.go: -------------------------------------------------------------------------------- 1 | package enumdecl 2 | 3 | type MyEnum int32 4 | 5 | const ( 6 | A MyEnum = iota 7 | B MyEnum = iota 8 | ) 9 | -------------------------------------------------------------------------------- /test/enumdecl_all/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. enumdeclall.proto 4 | -------------------------------------------------------------------------------- /test/enumdecl_all/enumdeclall.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package enumdeclall; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.testgen_all) = true; 8 | option (gogoproto.populate_all) = true; 9 | option (gogoproto.benchgen_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.marshaler_all) = true; 12 | option (gogoproto.sizer_all) = true; 13 | option (gogoproto.equal_all) = true; 14 | option (gogoproto.verbose_equal_all) = true; 15 | option (gogoproto.unsafe_marshaler_all) = false; 16 | option (gogoproto.unsafe_unmarshaler_all) = false; 17 | option (gogoproto.enumdecl_all) = false; 18 | 19 | enum MyEnum { 20 | option (gogoproto.goproto_enum_prefix) = false; 21 | A = 0; 22 | B = 1; 23 | } 24 | 25 | enum MyOtherEnum { 26 | option (gogoproto.enumdecl) = true; 27 | option (gogoproto.goproto_enum_prefix) = false; 28 | C = 0; 29 | D = 1; 30 | } 31 | 32 | message Message { 33 | MyEnum enumerated_field = 1; 34 | MyOtherEnum otherenumerated_field = 2; 35 | } 36 | -------------------------------------------------------------------------------- /test/enumdecl_all/models.go: -------------------------------------------------------------------------------- 1 | package enumdeclall 2 | 3 | type MyEnum int32 4 | 5 | const ( 6 | A MyEnum = iota 7 | B MyEnum = iota 8 | ) 9 | -------------------------------------------------------------------------------- /test/enumprefix/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. enumprefix.proto) 31 | -------------------------------------------------------------------------------- /test/enumprefix/enumprefix.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package enumprefix; 31 | 32 | import "github.com/gogo/protobuf/test/thetest.proto"; 33 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 34 | 35 | message MyMessage { 36 | optional test.TheTestEnum TheField = 1 [(gogoproto.nullable) = false]; 37 | } 38 | -------------------------------------------------------------------------------- /test/enumstringer/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. enumstringer.proto) 31 | -------------------------------------------------------------------------------- /test/enumstringer/string.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package enumstringer 30 | 31 | func (this TheTestEnum) String() string { 32 | switch this { 33 | case 0: 34 | return "a" 35 | case 1: 36 | return "blabla" 37 | case 2: 38 | return "z" 39 | } 40 | return "3" 41 | } 42 | -------------------------------------------------------------------------------- /test/example/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc -I=. -I=$(GOPATH)/src/github.com/gogo/protobuf/protobuf -I=$(GOPATH)/src --gogo_out=. example.proto) 31 | -------------------------------------------------------------------------------- /test/example/example_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package test 30 | 31 | import "testing" 32 | 33 | func TestGetterExists(t *testing.T) { 34 | _ = (&CastType{}).GetInt32() 35 | } 36 | -------------------------------------------------------------------------------- /test/filedotname/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | protoc --gogo_out=. --proto_path=../../protobuf/:../../../../../:. file.dot.proto 32 | -------------------------------------------------------------------------------- /test/fuzztests/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogofast 31 | protoc --proto_path=../../../../../:../../protobuf/:. --gogofast_out=. fuzz.proto 32 | -------------------------------------------------------------------------------- /test/group/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../protobuf/:../../../../../:. --gogo_out=. group.proto) 31 | -------------------------------------------------------------------------------- /test/importcustom-issue389/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | (cd imported && make regenerate) 3 | (cd importing && make regenerate) 4 | 5 | -------------------------------------------------------------------------------- /test/importcustom-issue389/imported/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | go install github.com/gogo/protobuf/protoc-min-version 4 | protoc-min-version --version="3.0.0" --proto_path=../../../../../../:../../../protobuf/:. --gogo_out=. a.proto -------------------------------------------------------------------------------- /test/importcustom-issue389/imported/a.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package imported; 3 | 4 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.sizer_all) = true; 7 | option (gogoproto.marshaler_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.testgen_all) = true; 10 | option (gogoproto.populate_all) = true; 11 | option (gogoproto.equal_all) = true; 12 | 13 | message A { 14 | string f1 = 1; 15 | } -------------------------------------------------------------------------------- /test/importcustom-issue389/imported/b.go: -------------------------------------------------------------------------------- 1 | package imported 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/gogo/protobuf/proto" 7 | ) 8 | 9 | type B struct { 10 | A 11 | } 12 | 13 | func (b B) Equal(other B) bool { 14 | return b.A.Equal(other.A) 15 | } 16 | 17 | func (b B) Size() int { 18 | return b.A.Size() 19 | } 20 | 21 | func NewPopulatedB(r randyA) *B { 22 | a := NewPopulatedA(r, true) 23 | if a == nil { 24 | return nil 25 | } 26 | return &B{*a} 27 | } 28 | 29 | func (b B) Marshal() ([]byte, error) { 30 | return proto.Marshal(&b.A) 31 | } 32 | 33 | func (b *B) Unmarshal(data []byte) error { 34 | a := &A{} 35 | err := proto.Unmarshal(data, a) 36 | if err != nil { 37 | return err 38 | } 39 | b.A = *a 40 | return nil 41 | } 42 | 43 | func (b B) MarshalJSON() ([]byte, error) { 44 | return json.Marshal(b.A) 45 | } 46 | 47 | func (b *B) UnmarshalJSON(data []byte) error { 48 | a := &A{} 49 | err := json.Unmarshal(data, a) 50 | if err != nil { 51 | return err 52 | } 53 | *b = B{A: *a} 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /test/importcustom-issue389/importing/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | go install github.com/gogo/protobuf/protoc-min-version 4 | protoc-min-version --version="3.0.0" --proto_path=../../../../../../:../../../protobuf/:. --gogo_out=. c.proto -------------------------------------------------------------------------------- /test/importcustom-issue389/importing/c.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package importing; 3 | 4 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 5 | import "github.com/gogo/protobuf/test/importcustom-issue389/imported/a.proto"; 6 | 7 | option (gogoproto.sizer_all) = true; 8 | option (gogoproto.marshaler_all) = true; 9 | option (gogoproto.unmarshaler_all) = true; 10 | option (gogoproto.testgen_all) = true; 11 | option (gogoproto.populate_all) = true; 12 | option (gogoproto.equal_all) = true; 13 | 14 | message C { 15 | imported.A f2 = 1 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/importcustom-issue389/imported.B"]; 16 | } -------------------------------------------------------------------------------- /test/importdedup/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. proto.proto) 31 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. subpkg/subproto.proto) 32 | -------------------------------------------------------------------------------- /test/importdedup/importdedup_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package importdedup 30 | 31 | import testing "testing" 32 | 33 | func TestImportDedup(t *testing.T) { 34 | } 35 | -------------------------------------------------------------------------------- /test/importdedup/subpkg/customtype.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package subpkg 30 | 31 | type CustomType struct{} 32 | -------------------------------------------------------------------------------- /test/importdedup/subpkg/subproto.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | package subpkg; 31 | 32 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 33 | 34 | message SubObject { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /test/importduplicate/importduplicate_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package importduplicate 30 | 31 | import testing "testing" 32 | 33 | func TestImportDuplicate(t *testing.T) { 34 | } 35 | -------------------------------------------------------------------------------- /test/indeximport-issue72/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (cd index && protoc --proto_path=../../../../../../:../../../protobuf/:. --gogo_out=. index.proto) 31 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. indeximport.proto) 32 | -------------------------------------------------------------------------------- /test/int64support/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc -I=. -I=../../../../../ -I=../../protobuf/ --gogo_out=. object.proto) 31 | -------------------------------------------------------------------------------- /test/int64support/object.proto: -------------------------------------------------------------------------------- 1 | package int64support; 2 | 3 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 4 | 5 | option go_package = "int64support"; 6 | option (gogoproto.benchgen_all) = true; 7 | option (gogoproto.enum_stringer_all) = true; 8 | option (gogoproto.equal_all) = true; 9 | option (gogoproto.goproto_enum_prefix_all) = false; 10 | option (gogoproto.goproto_enum_stringer_all) = false; 11 | option (gogoproto.goproto_stringer_all) = false; 12 | option (gogoproto.goproto_unrecognized_all) = false; 13 | option (gogoproto.gostring_all) = true; 14 | option (gogoproto.marshaler_all) = true; 15 | option (gogoproto.populate_all) = true; 16 | option (gogoproto.sizer_all) = true; 17 | option (gogoproto.stringer_all) = true; 18 | option (gogoproto.testgen_all) = true; 19 | option (gogoproto.unmarshaler_all) = true; 20 | option (gogoproto.verbose_equal_all) = true; 21 | 22 | message Object { 23 | optional int64 optional_number = 1; 24 | } 25 | -------------------------------------------------------------------------------- /test/int64support/object_js.go: -------------------------------------------------------------------------------- 1 | package int64support 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "strconv" 8 | ) 9 | 10 | var ( 11 | _ = json.Marshaler(new(Object)) 12 | _ = json.Unmarshaler(new(Object)) 13 | ) 14 | 15 | func (o *Object) MarshalJSON() ([]byte, error) { 16 | if o.OptionalNumber == nil { 17 | return ([]byte)("{}"), nil 18 | } 19 | return ([]byte)(fmt.Sprintf("{\"optional_number\": %d}", *o.OptionalNumber)), nil 20 | } 21 | 22 | func (o *Object) UnmarshalJSON(b []byte) error { 23 | var ( 24 | trim = func(v []byte) []byte { return bytes.Trim(v, " \n\r\t") } 25 | strip = func(v []byte, first, last byte) ([]byte, error) { 26 | x := len(v) 27 | if x < 2 || v[0] != first || v[x-1] != last { 28 | return nil, fmt.Errorf("failed to strip %q and %q from byte sequence", first, last) 29 | } 30 | return v[1 : x-1], nil 31 | } 32 | ) 33 | b, err := strip(trim(b), '{', '}') 34 | if err != nil { 35 | return err 36 | } 37 | // poor man parser: assume the only commas appear between JSON key-value pairs, 38 | // and that object hierarchy is flat 39 | for xf, f := range bytes.Split(b, ([]byte)(",")) { 40 | parts := bytes.SplitN(f, ([]byte)(":"), 2) 41 | if x := len(parts); x != 2 { 42 | if xf == 0 && (x == 0 || (x == 1 && len(trim(parts[0])) == 0)) { 43 | return nil // empty object 44 | } 45 | return fmt.Errorf("failed to parse field-value seperator char ':'") 46 | } 47 | fieldName, err := strip(trim(parts[0]), '"', '"') 48 | if err != nil { 49 | return err 50 | } 51 | if string(fieldName) != "optional_number" { 52 | continue // ignore unknown field 53 | } 54 | fieldValue := trim(parts[1]) 55 | v, err := strconv.ParseInt(string(fieldValue), 10, 64) 56 | if err != nil { 57 | return err 58 | } 59 | o.OptionalNumber = &v 60 | break 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /test/int64support/object_js_test.go: -------------------------------------------------------------------------------- 1 | package int64support 2 | 3 | import ( 4 | "encoding/json" 5 | "testing" 6 | ) 7 | 8 | func TestMarshaler(t *testing.T) { 9 | n := int64(1) 10 | b, err := json.Marshal(&Object{OptionalNumber: &n}) 11 | if err != nil { 12 | t.Fatal(err) 13 | } 14 | const expected = "{\"optional_number\":1}" 15 | if string(b) != expected { 16 | t.Fatalf("expected '%s' instead of '%s'", expected, string(b)) 17 | } 18 | 19 | b, err = json.Marshal(new(Object)) 20 | if err != nil { 21 | t.Fatal(err) 22 | } 23 | const expected2 = "{}" 24 | if string(b) != expected2 { 25 | t.Fatalf("expected '%s' instead of '%s'", expected2, string(b)) 26 | } 27 | } 28 | 29 | func TestUnmarshaler(t *testing.T) { 30 | o := new(Object) 31 | err := json.Unmarshal(([]byte)("{\"optional_number\": 1}"), o) 32 | if err != nil { 33 | t.Fatal(err) 34 | } 35 | if n := o.GetOptionalNumber(); n != 1 { 36 | t.Fatalf("expected 1 instead of %d", n) 37 | } 38 | 39 | o = new(Object) 40 | err = json.Unmarshal(([]byte)("{}"), o) 41 | if err != nil { 42 | t.Fatal(err) 43 | } 44 | if o.OptionalNumber != nil { 45 | t.Fatalf("expected nil OptionalNumber instead of %d", *o.OptionalNumber) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/issue260/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:. --proto_path=../../../../../:../../protobuf/:. issue260.proto 4 | -------------------------------------------------------------------------------- /test/issue260/README.md: -------------------------------------------------------------------------------- 1 | # The Bug 2 | 3 | If in a message the following options are set: 4 | 5 | * `typedecl` `false` 6 | * `go_getters` `false` 7 | * `marshaller` `true` 8 | 9 | And one of the fields is using the `stdtime` and `nullable` `false` extension (to 10 | use `time.Time` instead of the protobuf type), then an import to the _time_ package 11 | is added even if it is not needed. 12 | -------------------------------------------------------------------------------- /test/issue260/issue260.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package issue260; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | import "google/protobuf/timestamp.proto"; 7 | 8 | option (gogoproto.testgen_all) = true; 9 | option (gogoproto.populate_all) = true; 10 | option (gogoproto.benchgen_all) = true; 11 | option (gogoproto.unmarshaler_all) = true; 12 | option (gogoproto.marshaler_all) = true; 13 | option (gogoproto.sizer_all) = true; 14 | option (gogoproto.equal_all) = true; 15 | option (gogoproto.verbose_equal_all) = true; 16 | option (gogoproto.unsafe_marshaler_all) = false; 17 | option (gogoproto.unsafe_unmarshaler_all) = false; 18 | option (gogoproto.goproto_unrecognized_all) = false; 19 | 20 | message Dropped { 21 | option (gogoproto.typedecl) = false; 22 | string name = 1; 23 | int32 age = 2; 24 | } 25 | 26 | message DroppedWithoutGetters { 27 | option (gogoproto.typedecl) = false; 28 | option (gogoproto.goproto_getters) = false; 29 | int64 height = 1; 30 | int64 width = 2; 31 | google.protobuf.Timestamp timestamp = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; 32 | } 33 | 34 | message Kept { 35 | string name = 1; 36 | int32 age = 2; 37 | } 38 | -------------------------------------------------------------------------------- /test/issue260/models.go: -------------------------------------------------------------------------------- 1 | package issue260 2 | 3 | import ( 4 | "encoding/json" 5 | "time" 6 | 7 | "github.com/gogo/protobuf/jsonpb" 8 | ) 9 | 10 | type Dropped struct { 11 | Name string 12 | Age int32 13 | } 14 | 15 | func (d *Dropped) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error { 16 | return json.Unmarshal(b, d) 17 | } 18 | 19 | func (d *Dropped) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { 20 | return json.Marshal(d) 21 | } 22 | 23 | func (d *Dropped) Drop() bool { 24 | return true 25 | } 26 | 27 | type DroppedWithoutGetters struct { 28 | Width int64 29 | Height int64 30 | Timestamp time.Time `protobuf:"bytes,3,opt,name=timestamp,stdtime" json:"timestamp"` 31 | NullableTimestamp *time.Time `protobuf:"bytes,4,opt,name=nullable_timestamp,json=nullableTimestamp,stdtime" json:"nullable_timestamp,omitempty"` 32 | } 33 | 34 | func (d *DroppedWithoutGetters) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error { 35 | return json.Unmarshal(b, d) 36 | } 37 | 38 | func (d *DroppedWithoutGetters) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { 39 | return json.Marshal(d) 40 | } 41 | -------------------------------------------------------------------------------- /test/issue261/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-min-version 3 | go install github.com/gogo/protobuf/protoc-gen-gogoslick 4 | protoc-min-version --version="3.0.0" --gogoslick_out=\ 5 | Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\ 6 | :. \ 7 | --proto_path=../../../../../:../../protobuf/:. issue261.proto 8 | -------------------------------------------------------------------------------- /test/issue261/issue261.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package issue261; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | import "google/protobuf/duration.proto"; 8 | 9 | message MapStdTypes { 10 | map nullableDuration = 3 [(gogoproto.stdduration) = true]; 11 | } 12 | -------------------------------------------------------------------------------- /test/issue262/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-min-version 3 | go install github.com/gogo/protobuf/protoc-gen-gogoslick 4 | protoc-min-version --version="3.0.0" --proto_path=.:$(GOPATH)/src/:$(GOPATH)/src/github.com/gogo/protobuf/protobuf/ \ 5 | --gogoslick_out=Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:. timefail.proto 6 | -------------------------------------------------------------------------------- /test/issue262/timefail.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 4 | import "google/protobuf/timestamp.proto"; 5 | 6 | package timefail; 7 | 8 | message TimeFail { 9 | google.protobuf.Timestamp time_test = 1 [(gogoproto.stdtime) = true]; 10 | } -------------------------------------------------------------------------------- /test/issue270/a/a1.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package issue270.a; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | import "github.com/gogo/protobuf/test/issue270/a/a2.proto"; 7 | 8 | option (gogoproto.populate_all) = true; 9 | 10 | message A1 { 11 | optional A2 a2 = 1; 12 | } 13 | -------------------------------------------------------------------------------- /test/issue270/a/a2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package issue270.a; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | import "github.com/gogo/protobuf/test/issue270/b/b.proto"; 7 | 8 | option (gogoproto.populate_all) = true; 9 | 10 | message A2 { 11 | optional issue270.b.B b = 1; 12 | } 13 | -------------------------------------------------------------------------------- /test/issue270/b/b.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package issue270.b; 4 | 5 | message B { 6 | } 7 | -------------------------------------------------------------------------------- /test/issue270/doc.go: -------------------------------------------------------------------------------- 1 | package issue270 2 | -------------------------------------------------------------------------------- /test/issue312/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | protoc --proto_path=.:$(GOPATH)/src/:$(GOPATH)/src/github.com/gogo/protobuf/protobuf/ \ 3 | --gogo_out=. issue312.proto 4 | (cd events && make regenerate) 5 | -------------------------------------------------------------------------------- /test/issue312/events/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc --proto_path=.:$(GOPATH)/src/:$(GOPATH)/src/github.com/gogo/protobuf/protobuf/ \ 4 | --gogo_out=. events.proto 5 | -------------------------------------------------------------------------------- /test/issue312/events/events.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package issue312.events; 4 | 5 | import "github.com/gogo/protobuf/test/issue312/issue312.proto"; 6 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 7 | 8 | option go_package = "events"; 9 | option (gogoproto.gostring_all) = true; 10 | option (gogoproto.populate_all) = true; 11 | option (gogoproto.equal_all) = true; 12 | option (gogoproto.testgen_all) = true; 13 | 14 | message Subtype { 15 | optional issue312.TaskState state = 4; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/issue312/issue312.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package issue312; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option go_package = "issue312"; 8 | option (gogoproto.gostring_all) = true; 9 | option (gogoproto.populate_all) = true; 10 | option (gogoproto.equal_all) = true; 11 | option (gogoproto.testgen_all) = true; 12 | 13 | enum TaskState { 14 | TASK_STAGING = 6; 15 | TASK_STARTING = 0; 16 | TASK_RUNNING = 1; 17 | } 18 | -------------------------------------------------------------------------------- /test/issue322/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogofast 3 | protoc-min-version --version="3.0.0" --gogofast_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. --proto_path=../../../../../:../../protobuf/:. *.proto 4 | -------------------------------------------------------------------------------- /test/issue322/issue322.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package test; 3 | 4 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.gostring_all) = true; 7 | option (gogoproto.populate_all) = true; 8 | option (gogoproto.equal_all) = true; 9 | option (gogoproto.testgen_all) = true; 10 | option (gogoproto.compare_all) = true; 11 | 12 | message OneofTest { 13 | oneof union { 14 | int32 i = 1 [default = 4]; 15 | } 16 | } -------------------------------------------------------------------------------- /test/issue330/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. --proto_path=../../../../../:../../protobuf/:. *.proto 4 | -------------------------------------------------------------------------------- /test/issue330/issue330.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package issue330; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.benchgen_all) = true; 8 | option (gogoproto.equal_all) = true; 9 | option (gogoproto.marshaler_all) = true; 10 | option (gogoproto.populate_all) = true; 11 | option (gogoproto.sizer_all) = true; 12 | option (gogoproto.testgen_all) = true; 13 | option (gogoproto.unmarshaler_all) = true; 14 | 15 | message Object { 16 | uint32 type = 1 [(gogoproto.casttype) = "TypeIdentifier"]; 17 | } 18 | -------------------------------------------------------------------------------- /test/issue330/type.go: -------------------------------------------------------------------------------- 1 | package issue330 2 | 3 | type TypeIdentifier uint32 4 | 5 | const ( 6 | UnknownType TypeIdentifier = 0 7 | UserType TypeIdentifier = 20 8 | ) 9 | 10 | func (t TypeIdentifier) String() string { 11 | switch t { 12 | case 20: 13 | return "User" 14 | default: 15 | return "Unknown" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/issue34/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. proto.proto) 31 | -------------------------------------------------------------------------------- /test/issue34/proto.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | 31 | package issue34; 32 | 33 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 34 | 35 | option (gogoproto.unmarshaler_all) = true; 36 | 37 | message Foo { 38 | optional bytes bar = 1; 39 | } 40 | 41 | message FooWithRepeated { 42 | repeated bytes bar = 1; 43 | } 44 | -------------------------------------------------------------------------------- /test/issue411/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:. --proto_path=../../../../../:../../protobuf/:. issue411.proto 4 | -------------------------------------------------------------------------------- /test/issue427/.gitignore: -------------------------------------------------------------------------------- 1 | *.pb.go 2 | *_test.go -------------------------------------------------------------------------------- /test/issue427/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | go install github.com/gogo/protobuf/protoc-min-version 4 | go get -u golang.org/x/net/context 5 | go get -u google.golang.org/grpc 6 | protoc-min-version --version="3.0.0" --gogo_out=plugins=grpc:. --proto_path=../../../../../:../../protobuf/:. issue427.proto 7 | go test ./... 8 | -------------------------------------------------------------------------------- /test/issue427/README.md: -------------------------------------------------------------------------------- 1 | # The Bug 2 | 3 | Inconsistent package name generation between the import: 4 | 5 | * import golang_org_x_net_context "golang.org/x/net/context" 6 | * import google_golang_org_grpc "google.golang.org/grpc" 7 | 8 | and the dummy vars: 9 | 10 | * var _ context.Context 11 | * var _ grpc.ClientConn 12 | -------------------------------------------------------------------------------- /test/issue427/issue427.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package issue427; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.testgen_all) = true; 8 | option (gogoproto.populate_all) = true; 9 | option (gogoproto.sizer_all) = true; 10 | option (gogoproto.equal_all) = true; 11 | 12 | message Foo { 13 | string foo = 1; 14 | } 15 | 16 | service Bar { 17 | rpc GetBar (Foo) returns (Foo); 18 | } -------------------------------------------------------------------------------- /test/issue42order/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. issue42.proto) 31 | -------------------------------------------------------------------------------- /test/issue435/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc --gogo_out=. --proto_path=../../../../../:../../protobuf/:. *.proto 4 | -------------------------------------------------------------------------------- /test/issue435/issue435.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package issue435; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option go_package = "issue435"; 8 | 9 | message Message { 10 | optional SubMessage nonnullable_optional = 1 [(gogoproto.nullable) = false]; 11 | repeated SubMessage nonnullable_repeated = 2 [(gogoproto.nullable) = false]; 12 | } 13 | 14 | message SubMessage { 15 | optional int64 value = 1 [default = 7]; 16 | } -------------------------------------------------------------------------------- /test/issue435/issue435pb_test.go: -------------------------------------------------------------------------------- 1 | package issue435 2 | 3 | import ( 4 | "testing" 5 | 6 | proto "github.com/gogo/protobuf/proto" 7 | ) 8 | 9 | func TestNonnullableDefaults(t *testing.T) { 10 | m := &Message{ 11 | NonnullableOptional: SubMessage{}, 12 | NonnullableRepeated: []SubMessage{{}}, 13 | } 14 | proto.SetDefaults(m) 15 | 16 | if e, a := int64(7), *m.NonnullableOptional.Value; e != a { 17 | t.Errorf("Default not set: want %d, got %d", e, a) 18 | } 19 | if e, a := int64(7), *m.NonnullableRepeated[0].Value; e != a { 20 | t.Errorf("Default not set: want %d, got %d", e, a) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/issue438/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | go install github.com/gogo/protobuf/protoc-min-version 4 | protoc-min-version --version="3.0.0" --gogo_out=\ 5 | Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\ 6 | Mgoogle/protobuf/api.proto=github.com/gogo/protobuf/types,\ 7 | Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\ 8 | Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\ 9 | Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types,\ 10 | Mgoogle/protobuf/source_context.proto=github.com/gogo/protobuf/types,\ 11 | Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\ 12 | Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\ 13 | Mgoogle/protobuf/type.proto=github.com/gogo/protobuf/types,\ 14 | Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\ 15 | :. --proto_path=../../../../../:../../protobuf/:. issue438.proto 16 | -------------------------------------------------------------------------------- /test/issue444/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-min-version 31 | protoc-min-version --version="3.0.0" --proto_path=\ 32 | .:$(GOPATH)/src/:$(GOPATH)/src/github.com/gogo/protobuf/protobuf/ \ 33 | --gogo_out=. issue444.proto 34 | -------------------------------------------------------------------------------- /test/issue444/issue444.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto3"; 30 | 31 | package issue444; 32 | 33 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 34 | 35 | option (gogoproto.sizer_all) = true; 36 | 37 | message SizeMe { 38 | string foo = 1; 39 | } -------------------------------------------------------------------------------- /test/issue444/issue444_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package issue444 30 | 31 | import ( 32 | "testing" 33 | ) 34 | 35 | func TestNilStructSize(t *testing.T) { 36 | var sm *SizeMe 37 | n := sm.Size() 38 | if n != 0 { 39 | t.Fatalf("expected 0 size with a nil struct") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/issue449/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | go install github.com/gogo/protobuf/protoc-min-version 32 | protoc-min-version --version="3.0.0" \ 33 | --proto_path=../../../../../:../../protobuf/:. \ 34 | --gogo_out=. issue449.proto 35 | -------------------------------------------------------------------------------- /test/issue498/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-min-version 31 | go install github.com/gogo/protobuf/protoc-gen-gogo 32 | protoc-min-version --version="3.0.0" --proto_path=\ 33 | .:$(GOPATH)/src/:$(GOPATH)/src/github.com/gogo/protobuf/protobuf/ \ 34 | --gogofast_out=. issue498.proto 35 | -------------------------------------------------------------------------------- /test/issue503/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2019, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | go install github.com/gogo/protobuf/protoc-min-version 32 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. *.proto 33 | -------------------------------------------------------------------------------- /test/issue530/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2019, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | go install github.com/gogo/protobuf/protoc-min-version 32 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. *.proto 33 | -------------------------------------------------------------------------------- /test/issue617/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2019, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | go install github.com/gogo/protobuf/protoc-min-version 32 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. *.proto 33 | -------------------------------------------------------------------------------- /test/issue620/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2019, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. issue620.proto 32 | -------------------------------------------------------------------------------- /test/issue630/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../protobuf/:../../../../../:. --gogo_out=. issue630.proto) 31 | -------------------------------------------------------------------------------- /test/issue8/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. proto.proto) 31 | -------------------------------------------------------------------------------- /test/jsonpb-gogo/jsonpb_gogo.go: -------------------------------------------------------------------------------- 1 | package jsonpb_gogo 2 | -------------------------------------------------------------------------------- /test/jsonpb-gogo/jsonpb_gogo_test.go: -------------------------------------------------------------------------------- 1 | package jsonpb_gogo 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gogo/protobuf/jsonpb" 7 | ) 8 | 9 | // customFieldMessage implements protobuf.Message but is not a normal generated message type. 10 | type customFieldMessage struct { 11 | someField string //this is not a proto field 12 | } 13 | 14 | func (m *customFieldMessage) Reset() { 15 | m.someField = "hello" 16 | } 17 | 18 | func (m *customFieldMessage) String() string { 19 | return m.someField 20 | } 21 | 22 | func (m *customFieldMessage) ProtoMessage() { 23 | } 24 | 25 | func TestUnmarshalWithJSONPBUnmarshaler(t *testing.T) { 26 | rawJson := `{}` 27 | marshaler := &jsonpb.Marshaler{} 28 | msg := &customFieldMessage{someField: "Ignore me"} 29 | str, err := marshaler.MarshalToString(msg) 30 | if err != nil { 31 | t.Errorf("an unexpected error occurred when marshaling message: %v", err) 32 | } 33 | if str != rawJson { 34 | t.Errorf("marshaled JSON was incorrect: got %s, wanted %s", str, rawJson) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/mapsproto2/doc.go: -------------------------------------------------------------------------------- 1 | package mapsproto2 2 | -------------------------------------------------------------------------------- /test/merge/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-min-version 3 | go install github.com/gogo/protobuf/protoc-gen-gogo 4 | protoc-min-version --version="3.0.0" --gogo_out=. \ 5 | --proto_path=../../../../../:../../protobuf/:. merge.proto 6 | -------------------------------------------------------------------------------- /test/merge/merge.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package merge; 3 | 4 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 5 | 6 | message A { 7 | B B = 1 [(gogoproto.nullable) = false]; 8 | repeated C c = 2 [(gogoproto.nullable) = false]; 9 | } 10 | 11 | message B { 12 | int64 c = 1; 13 | } 14 | 15 | message C { 16 | int64 d = 1; 17 | } 18 | -------------------------------------------------------------------------------- /test/merge/merge_test.go: -------------------------------------------------------------------------------- 1 | package merge 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "testing" 7 | 8 | "github.com/gogo/protobuf/proto" 9 | ) 10 | 11 | func TestClone1(t *testing.T) { 12 | f1 := &A{} 13 | proto.Clone(f1) 14 | } 15 | 16 | func TestClone2(t *testing.T) { 17 | f1 := &A{C: []C{{D: 1}, {D: 2}}} 18 | f2 := proto.Clone(f1).(*A) 19 | if !reflect.DeepEqual(f1.C, f2.C) { 20 | t.Fatalf("got %v want %v", f2, f1) 21 | } 22 | if fmt.Sprintf("%p", f1.C) == fmt.Sprintf("%p", f2.C) { 23 | t.Fatalf("slice is not deep copied") 24 | } 25 | } 26 | 27 | func TestMerge1(t *testing.T) { 28 | f1 := &A{} 29 | f2 := &A{} 30 | proto.Merge(f1, f2) 31 | } 32 | 33 | func TestMerge2(t *testing.T) { 34 | f1 := &A{B: B{C: 1}} 35 | f2 := &A{} 36 | proto.Merge(f1, f2) 37 | if f1.B.C != 1 { 38 | t.Fatalf("got %d want %d", f1.B.C, 1) 39 | } 40 | } 41 | 42 | func TestMerge3(t *testing.T) { 43 | f1 := &A{} 44 | f2 := &A{B: B{C: 1}} 45 | proto.Merge(f1, f2) 46 | if f1.B.C != 1 { 47 | t.Fatalf("got %d want %d", f1.B.C, 1) 48 | } 49 | } 50 | 51 | func TestMerge4(t *testing.T) { 52 | f1 := &A{} 53 | f2 := &A{C: []C{}} 54 | proto.Merge(f1, f2) 55 | if f1.C == nil { 56 | t.Fatalf("got %v want %v", f1, []C{}) 57 | } 58 | } 59 | 60 | func TestMerge5(t *testing.T) { 61 | f1 := &A{C: []C{{D: 1}, {D: 2}}} 62 | f2 := &A{C: []C{{D: 3}, {D: 4}}} 63 | f3 := &A{C: []C{{D: 1}, {D: 2}, {D: 3}, {D: 4}}} 64 | proto.Merge(f1, f2) 65 | if !reflect.DeepEqual(f1, f3) { 66 | t.Fatalf("got %v want %v", f1, f3) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /test/mixbench/.gitignore: -------------------------------------------------------------------------------- 1 | mixbench -------------------------------------------------------------------------------- /test/moredefaults/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. md.proto) 31 | -------------------------------------------------------------------------------- /test/nopackage/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc-min-version --version="3.0.0" --proto_path=../../../../../:../../protobuf/:. --gogofast_out=. nopackage.proto) 31 | -------------------------------------------------------------------------------- /test/nopackage/nopackage.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto3"; 30 | 31 | message M { 32 | map f = 1; 33 | } 34 | -------------------------------------------------------------------------------- /test/nopackage/nopackage_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package nopackage 30 | 31 | import ( 32 | "testing" 33 | ) 34 | 35 | func TestNoPackage(t *testing.T) { 36 | //should compile 37 | _ = (&M{}).Marshal 38 | } 39 | -------------------------------------------------------------------------------- /test/oneof/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-combo 31 | go install github.com/gogo/protobuf/protoc-gen-gogo 32 | protoc-gen-combo --version="2.6.0" --gogo_out=. --proto_path=../../protobuf/:../../../../../:. one.proto 33 | -------------------------------------------------------------------------------- /test/oneof/doc.go: -------------------------------------------------------------------------------- 1 | package one 2 | -------------------------------------------------------------------------------- /test/oneof3/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-combo 31 | go install github.com/gogo/protobuf/protoc-gen-gogo 32 | protoc-gen-combo --version="3.0.0" --gogo_out=. --proto_path=../../protobuf/:../../../../../:. one.proto 33 | -------------------------------------------------------------------------------- /test/oneof3/doc.go: -------------------------------------------------------------------------------- 1 | package oneof3 2 | -------------------------------------------------------------------------------- /test/oneofembed/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | protoc-min-version --proto_path=../../../../../:../../protobuf/:. --version="3.0.0" --gogo_out=. *.proto 31 | 32 | -------------------------------------------------------------------------------- /test/packed/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. packed.proto) 31 | -------------------------------------------------------------------------------- /test/packed/doc.go: -------------------------------------------------------------------------------- 1 | package packed 2 | -------------------------------------------------------------------------------- /test/proto3extension/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | go install github.com/gogo/protobuf/protoc-min-version 32 | protoc-min-version --version="3.0.0" --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. --proto_path=../../../../../:../../protobuf/:. *.proto -------------------------------------------------------------------------------- /test/proto3extension/proto3ext.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package proto3extension; 4 | 5 | import "google/protobuf/descriptor.proto"; 6 | 7 | extend google.protobuf.FieldOptions { 8 | bool primary = 51234; 9 | bool index = 51235; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test/protobuffer/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2019, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | protoc --gogo_out=. --proto_path=../../../../../:../../protobuf/:. *.proto 32 | -------------------------------------------------------------------------------- /test/protosize/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. protosize.proto) 31 | -------------------------------------------------------------------------------- /test/protosize/protosize_test.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | package protosize 30 | 31 | // We expect that Size field will have no suffix and ProtoSize will be present 32 | var ( 33 | _ = SizeMessage{}.Size 34 | _ = (&SizeMessage{}).GetSize 35 | 36 | _ = (&SizeMessage{}).ProtoSize 37 | ) 38 | -------------------------------------------------------------------------------- /test/registration/.gitignore: -------------------------------------------------------------------------------- 1 | *.pb.go 2 | *_test.go 3 | -------------------------------------------------------------------------------- /test/registration/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2017, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | test: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. registration.proto) 32 | cp registration_test.go.in registration_test.go 33 | go test ./... 34 | -------------------------------------------------------------------------------- /test/required/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. requiredexample.proto) 31 | -------------------------------------------------------------------------------- /test/setextensionbytes/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2019, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | protoc --gogo_out=. --proto_path=../../../../../:../../protobuf/:. *.proto 32 | -------------------------------------------------------------------------------- /test/sizerconflict/doc.go: -------------------------------------------------------------------------------- 1 | package sizerconflict 2 | -------------------------------------------------------------------------------- /test/sizeunderscore/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. sizeunderscore.proto) 31 | -------------------------------------------------------------------------------- /test/stdtypes/concurrency_test.go: -------------------------------------------------------------------------------- 1 | package stdtypes 2 | 3 | import ( 4 | "io/ioutil" 5 | "sync" 6 | "testing" 7 | 8 | "github.com/gogo/protobuf/proto" 9 | ) 10 | 11 | func TestConcurrentTextMarshal(t *testing.T) { 12 | // Verify that there are no race conditions when calling 13 | // TextMarshaler.Marshal on a protobuf message that contains a StdDuration 14 | 15 | std := StdTypes{} 16 | var wg sync.WaitGroup 17 | 18 | tm := proto.TextMarshaler{} 19 | 20 | for i := 0; i < 2; i++ { 21 | wg.Add(1) 22 | go func() { 23 | defer wg.Done() 24 | err := tm.Marshal(ioutil.Discard, &std) 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | }() 29 | } 30 | wg.Wait() 31 | } 32 | -------------------------------------------------------------------------------- /test/t.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | 7 | "github.com/gogo/protobuf/proto" 8 | ) 9 | 10 | type T struct { 11 | Data string 12 | } 13 | 14 | func (gt *T) protoType() *ProtoType { 15 | return &ProtoType{ 16 | Field2: >.Data, 17 | } 18 | } 19 | 20 | func (gt T) Equal(other T) bool { 21 | return gt.protoType().Equal(other.protoType()) 22 | } 23 | 24 | func (gt *T) Size() int { 25 | proto := &ProtoType{ 26 | Field2: >.Data, 27 | } 28 | return proto.Size() 29 | } 30 | 31 | func NewPopulatedT(r randyThetest) *T { 32 | data := NewPopulatedProtoType(r, false).Field2 33 | gt := &T{} 34 | if data != nil { 35 | gt.Data = *data 36 | } 37 | return gt 38 | } 39 | 40 | func (r T) Marshal() ([]byte, error) { 41 | return proto.Marshal(r.protoType()) 42 | } 43 | 44 | func (r *T) Unmarshal(data []byte) error { 45 | pr := &ProtoType{} 46 | err := proto.Unmarshal(data, pr) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | if pr.Field2 != nil { 52 | r.Data = *pr.Field2 53 | } 54 | return nil 55 | } 56 | 57 | func (gt T) MarshalJSON() ([]byte, error) { 58 | return json.Marshal(gt.Data) 59 | } 60 | 61 | func (gt *T) UnmarshalJSON(data []byte) error { 62 | var s string 63 | err := json.Unmarshal(data, &s) 64 | if err != nil { 65 | return err 66 | } 67 | *gt = T{Data: s} 68 | return nil 69 | } 70 | 71 | func (gt T) Compare(other T) int { 72 | return strings.Compare(gt.Data, other.Data) 73 | } 74 | -------------------------------------------------------------------------------- /test/tags/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. tags.proto) 31 | -------------------------------------------------------------------------------- /test/tags/doc.go: -------------------------------------------------------------------------------- 1 | package tags 2 | -------------------------------------------------------------------------------- /test/theproto3/doc.go: -------------------------------------------------------------------------------- 1 | package theproto3 2 | -------------------------------------------------------------------------------- /test/theproto3/footer.proto: -------------------------------------------------------------------------------- 1 | 2 | message MessageWithMap { 3 | map name_mapping = 1; 4 | map msg_mapping = 2; 5 | map byte_mapping = 3; 6 | } 7 | 8 | message FloatingPoint { 9 | double f = 1; 10 | } 11 | 12 | message Uint128Pair { 13 | bytes left = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"]; 14 | bytes right = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128"]; 15 | } 16 | 17 | message ContainsNestedMap { 18 | message NestedMap { 19 | map NestedMapField = 1; 20 | } 21 | } 22 | 23 | message NotPacked { 24 | repeated uint64 key = 5 [packed=false]; 25 | } -------------------------------------------------------------------------------- /test/theproto3/maps.proto: -------------------------------------------------------------------------------- 1 | 2 | enum MapEnum { 3 | MA = 0; 4 | MB = 1; 5 | MC = 2; 6 | } 7 | 8 | message AllMaps { 9 | map StringToDoubleMap = 1; 10 | map StringToFloatMap = 2; 11 | map Int32Map = 3; 12 | map Int64Map = 4; 13 | map Uint32Map = 5; 14 | map Uint64Map = 6; 15 | map Sint32Map = 7; 16 | map Sint64Map = 8; 17 | map Fixed32Map = 9; 18 | map Sfixed32Map = 10; 19 | map Fixed64Map = 11; 20 | map Sfixed64Map = 12; 21 | map BoolMap = 13; 22 | map StringMap = 14; 23 | map StringToBytesMap = 15; 24 | map StringToEnumMap = 16; 25 | map StringToMsgMap = 17; 26 | } 27 | 28 | message AllMapsOrdered { 29 | option (gogoproto.stable_marshaler) = true; 30 | 31 | map StringToDoubleMap = 1; 32 | map StringToFloatMap = 2; 33 | map Int32Map = 3; 34 | map Int64Map = 4; 35 | map Uint32Map = 5; 36 | map Uint64Map = 6; 37 | map Sint32Map = 7; 38 | map Sint64Map = 8; 39 | map Fixed32Map = 9; 40 | map Sfixed32Map = 10; 41 | map Fixed64Map = 11; 42 | map Sfixed64Map = 12; 43 | map BoolMap = 13; 44 | map StringMap = 14; 45 | map StringToBytesMap = 15; 46 | map StringToEnumMap = 16; 47 | map StringToMsgMap = 17; 48 | } 49 | -------------------------------------------------------------------------------- /test/typedecl/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. typedecl.proto 4 | -------------------------------------------------------------------------------- /test/typedecl/models.go: -------------------------------------------------------------------------------- 1 | package typedecl 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/gogo/protobuf/jsonpb" 7 | ) 8 | 9 | type Dropped struct { 10 | Name string 11 | Age int32 12 | } 13 | 14 | func (d *Dropped) Drop() bool { 15 | return true 16 | } 17 | 18 | func (d *Dropped) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error { 19 | return json.Unmarshal(b, d) 20 | } 21 | 22 | func (d *Dropped) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { 23 | return json.Marshal(d) 24 | } 25 | 26 | type DroppedWithoutGetters struct { 27 | Width int64 28 | Height int64 29 | } 30 | 31 | func (d *DroppedWithoutGetters) GetHeight() int64 { 32 | return d.Height 33 | } 34 | 35 | func (d *DroppedWithoutGetters) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error { 36 | return json.Unmarshal(b, d) 37 | } 38 | 39 | func (d *DroppedWithoutGetters) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { 40 | return json.Marshal(d) 41 | } 42 | -------------------------------------------------------------------------------- /test/typedecl/typedecl.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package typedecl; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.testgen_all) = true; 8 | option (gogoproto.populate_all) = true; 9 | option (gogoproto.benchgen_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.marshaler_all) = true; 12 | option (gogoproto.sizer_all) = true; 13 | option (gogoproto.equal_all) = true; 14 | option (gogoproto.verbose_equal_all) = true; 15 | option (gogoproto.unsafe_marshaler_all) = false; 16 | option (gogoproto.unsafe_unmarshaler_all) = false; 17 | option (gogoproto.goproto_unrecognized_all) = false; 18 | 19 | message Dropped { 20 | option (gogoproto.typedecl) = false; 21 | string name = 1; 22 | int32 age = 2; 23 | } 24 | 25 | message DroppedWithoutGetters { 26 | option (gogoproto.typedecl) = false; 27 | option (gogoproto.goproto_getters) = false; 28 | int64 height = 1; 29 | int64 width = 2; 30 | } 31 | 32 | message Kept { 33 | string name = 1; 34 | int32 age = 2; 35 | } 36 | -------------------------------------------------------------------------------- /test/typedecl_all/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. typedeclall.proto 4 | -------------------------------------------------------------------------------- /test/typedecl_all/models.go: -------------------------------------------------------------------------------- 1 | package typedeclall 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/gogo/protobuf/jsonpb" 7 | ) 8 | 9 | type Dropped struct { 10 | Name string 11 | Age int32 12 | } 13 | 14 | func (d *Dropped) Drop() bool { 15 | return true 16 | } 17 | 18 | func (d *Dropped) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error { 19 | return json.Unmarshal(b, d) 20 | } 21 | 22 | func (d *Dropped) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { 23 | return json.Marshal(d) 24 | } 25 | 26 | type DroppedWithoutGetters struct { 27 | Width int64 28 | Height int64 29 | } 30 | 31 | func (d *DroppedWithoutGetters) GetHeight() int64 { 32 | return d.Height 33 | } 34 | 35 | func (d *DroppedWithoutGetters) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error { 36 | return json.Unmarshal(b, d) 37 | } 38 | 39 | func (d *DroppedWithoutGetters) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { 40 | return json.Marshal(d) 41 | } 42 | -------------------------------------------------------------------------------- /test/typedecl_all/typedeclall.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package typedeclall; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.testgen_all) = true; 8 | option (gogoproto.populate_all) = true; 9 | option (gogoproto.benchgen_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.marshaler_all) = true; 12 | option (gogoproto.sizer_all) = true; 13 | option (gogoproto.equal_all) = true; 14 | option (gogoproto.verbose_equal_all) = true; 15 | option (gogoproto.unsafe_marshaler_all) = false; 16 | option (gogoproto.unsafe_unmarshaler_all) = false; 17 | option (gogoproto.goproto_unrecognized_all) = false; 18 | option (gogoproto.typedecl_all) = false; 19 | 20 | message Dropped { 21 | string name = 1; 22 | int32 age = 2; 23 | } 24 | 25 | message DroppedWithoutGetters { 26 | option (gogoproto.goproto_getters) = false; 27 | int64 height = 1; 28 | int64 width = 2; 29 | } 30 | 31 | message Kept { 32 | option (gogoproto.typedecl) = true; 33 | string name = 1; 34 | int32 age = 2; 35 | } 36 | -------------------------------------------------------------------------------- /test/typedeclimport/Makefile: -------------------------------------------------------------------------------- 1 | regenerate: 2 | go install github.com/gogo/protobuf/protoc-gen-gogo 3 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. typedeclimport.proto 4 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. ./subpkg/subpkg.proto -------------------------------------------------------------------------------- /test/typedeclimport/models.go: -------------------------------------------------------------------------------- 1 | package typedeclimport 2 | 3 | import subpkg "github.com/gogo/protobuf/test/typedeclimport/subpkg" 4 | 5 | type SomeMessage struct { 6 | Imported subpkg.AnotherMessage 7 | } 8 | -------------------------------------------------------------------------------- /test/typedeclimport/subpkg/subpkg.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package subpkg; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.marshaler_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.sizer_all) = true; 10 | option (gogoproto.equal_all) = true; 11 | option (gogoproto.verbose_equal_all) = true; 12 | 13 | message AnotherMessage { 14 | string foo = 1; 15 | } -------------------------------------------------------------------------------- /test/typedeclimport/typedeclimport.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package typedeclimport; 4 | 5 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 6 | 7 | import "github.com/gogo/protobuf/test/typedeclimport/subpkg/subpkg.proto"; 8 | 9 | option (gogoproto.unmarshaler_all) = true; 10 | option (gogoproto.marshaler_all) = true; 11 | option (gogoproto.sizer_all) = true; 12 | option (gogoproto.equal_all) = true; 13 | option (gogoproto.verbose_equal_all) = true; 14 | 15 | message SomeMessage { 16 | option (gogoproto.typedecl) = false; 17 | subpkg.AnotherMessage imported = 1 [(gogoproto.nullable) = false]; 18 | } -------------------------------------------------------------------------------- /test/typedeclimport/typedeclimport_test.go: -------------------------------------------------------------------------------- 1 | package typedeclimport 2 | 3 | import "testing" 4 | 5 | func Test(t *testing.T) { 6 | // No need to do anything, if this test runs, it means it works 7 | } 8 | -------------------------------------------------------------------------------- /test/unmarshalmerge/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../../../../:../../protobuf/:. --gogo_out=. unmarshalmerge.proto) 31 | -------------------------------------------------------------------------------- /test/unrecognized/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../protobuf/:../../../../../:. --gogo_out=. unrecognized.proto) 31 | -------------------------------------------------------------------------------- /test/unrecognizedgroup/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | (protoc --proto_path=../../protobuf/:../../../../../:. --gogo_out=. unrecognizedgroup.proto) 31 | -------------------------------------------------------------------------------- /test/xxxfields/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-combo 31 | go install github.com/gogo/protobuf/protoc-gen-gogo 32 | protoc-min-version --version="3.0.0" --gogo_out=. --proto_path=../../../../../:../../protobuf/:. xxxfields.proto 33 | -------------------------------------------------------------------------------- /types/doc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | /* 33 | Package types contains code for interacting with well-known types. 34 | */ 35 | package types 36 | -------------------------------------------------------------------------------- /vanity/test/doc.go: -------------------------------------------------------------------------------- 1 | package test 2 | -------------------------------------------------------------------------------- /vanity/test/gofast/.gitignore: -------------------------------------------------------------------------------- 1 | *.pb.go -------------------------------------------------------------------------------- /vanity/test/gogovanity.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | 31 | package vanity; 32 | 33 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 34 | 35 | message B { 36 | optional string String = 1 [(gogoproto.nullable) = true]; 37 | optional int64 Int64 = 2; 38 | optional int32 Int32 = 3 [default = 1234]; 39 | } 40 | -------------------------------------------------------------------------------- /vanity/test/proto3.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto3"; 30 | 31 | package vanity; 32 | 33 | message Aproto3 { 34 | string B = 1; 35 | } 36 | -------------------------------------------------------------------------------- /vanity/test/vanity.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2015, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | syntax = "proto2"; 30 | 31 | package vanity; 32 | 33 | message A { 34 | optional string Strings = 1; 35 | required int64 Int = 2; 36 | } 37 | --------------------------------------------------------------------------------