{"id":13367028,"url":"https://github.com/GoGo/protobuf","last_synced_at":"2025-03-12T18:31:48.276Z","repository":{"id":24096442,"uuid":"27483832","full_name":"gogo/protobuf","owner":"gogo","description":"[Deprecated] Protocol Buffers for Go with Gadgets","archived":false,"fork":false,"pushed_at":"2023-07-27T11:52:49.000Z","size":40269,"stargazers_count":5675,"open_issues_count":237,"forks_count":811,"subscribers_count":103,"default_branch":"master","last_synced_at":"2025-03-10T04:18:00.383Z","etag":null,"topics":["go","golang","grpc","protobuf","protocol-buffers"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gogo.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-12-03T11:27:10.000Z","updated_at":"2025-03-06T05:11:49.000Z","dependencies_parsed_at":"2023-01-14T13:30:51.425Z","dependency_job_id":"12cfc6cb-db90-4d45-9f3a-b85650e12702","html_url":"https://github.com/gogo/protobuf","commit_stats":{"total_commits":991,"total_committers":69,"mean_commits":14.36231884057971,"dds":0.2674066599394551,"last_synced_commit":"f67b8970b736e53dbd7d0a27146c8f1ac52f74e5"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogo%2Fprotobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogo%2Fprotobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogo%2Fprotobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogo%2Fprotobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gogo","download_url":"https://codeload.github.com/gogo/protobuf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243271386,"owners_count":20264449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","grpc","protobuf","protocol-buffers"],"created_at":"2024-07-30T00:01:36.687Z","updated_at":"2025-03-12T18:31:48.255Z","avatar_url":"https://github.com/gogo.png","language":"Go","funding_links":[],"categories":["序列化"],"sub_categories":["高级控制台界面","高級控制台界面"],"readme":"Protocol Buffers for Go with Gadgets\n\nGoGoProtobuf http://github.com/gogo/protobuf extends\nGoProtobuf http://github.com/golang/protobuf\n\nCopyright (c) 2013, The GoGo Authors. All rights reserved.\n\n\n# Go support for Protocol Buffers\n\nGoogle's data interchange format.\nCopyright 2010 The Go Authors.\nhttps://github.com/golang/protobuf\n\nThis package and the code it generates requires at least Go 1.6.\n\nThis software implements Go bindings for protocol buffers.  For\ninformation about protocol buffers themselves, see\n\thttps://developers.google.com/protocol-buffers/\n\n## Installation ##\n\nTo use this software, you must:\n- Install the standard C++ implementation of protocol buffers from\n\thttps://developers.google.com/protocol-buffers/\n- Of course, install the Go compiler and tools from\n\thttps://golang.org/\n  See\n\thttps://golang.org/doc/install\n  for details or, if you are using gccgo, follow the instructions at\n\thttps://golang.org/doc/install/gccgo\n- Grab the code from the repository and install the `proto` package.\n  The simplest way is to run `go get -u github.com/golang/protobuf/protoc-gen-go`.\n  The compiler plugin, `protoc-gen-go`, will be installed in `$GOPATH/bin`\n  unless `$GOBIN` is set. It must be in your `$PATH` for the protocol\n  compiler, `protoc`, to find it.\n- If you need a particular version of `protoc-gen-go` (e.g., to match your\n  `proto` package version), one option is\n  ```shell\n  GIT_TAG=\"v1.2.0\" # change as needed\n  go get -d -u github.com/golang/protobuf/protoc-gen-go\n  git -C \"$(go env GOPATH)\"/src/github.com/golang/protobuf checkout $GIT_TAG\n  go install github.com/golang/protobuf/protoc-gen-go\n  ```\n\nThis software has two parts: a 'protocol compiler plugin' that\ngenerates Go source files that, once compiled, can access and manage\nprotocol buffers; and a library that implements run-time support for\nencoding (marshaling), decoding (unmarshaling), and accessing protocol\nbuffers.\n\nThere is support for gRPC in Go using protocol buffers.\nSee the note at the bottom of this file for details.\n\nThere are no insertion points in the plugin.\n\nGoGoProtobuf provides extensions for protocol buffers and GoProtobuf\nsee http://github.com/gogo/protobuf/gogoproto/doc.go\n\n## Using protocol buffers with Go ##\n\nOnce the software is installed, there are two steps to using it.\nFirst you must compile the protocol buffer definitions and then import\nthem, with the support library, into your program.\n\nTo compile the protocol buffer definition, run protoc with the --gogo_out\nparameter set to the directory you want to output the Go code to.\n\n\tprotoc --gogo_out=. *.proto\n\nThe generated files will be suffixed .pb.go.  See the Test code below\nfor an example using such a file.\n\n## Packages and input paths ##\n\nThe protocol buffer language has a concept of \"packages\" which does not\ncorrespond well to the Go notion of packages. In generated Go code,\neach source `.proto` file is associated with a single Go package. The\nname and import path for this package is specified with the `go_package`\nproto option:\n\n\toption go_package = \"github.com/gogo/protobuf/types\";\n\nThe protocol buffer compiler will attempt to derive a package name and\nimport path if a `go_package` option is not present, but it is\nbest to always specify one explicitly.\n\nThere is a one-to-one relationship between source `.proto` files and\ngenerated `.pb.go` files, but any number of `.pb.go` files may be\ncontained in the same Go package.\n\nThe output name of a generated file is produced by replacing the\n`.proto` suffix with `.pb.go` (e.g., `foo.proto` produces `foo.pb.go`).\nHowever, the output directory is selected in one of two ways.  Let\nus say we have `inputs/x.proto` with a `go_package` option of\n`github.com/golang/protobuf/p`. The corresponding output file may\nbe:\n\n- Relative to the import path:\n\n\tprotoc --gogo_out=. inputs/x.proto\n\t# writes ./github.com/gogo/protobuf/p/x.pb.go\n\n  (This can work well with `--gogo_out=$GOPATH`.)\n\n- Relative to the input file:\n\n\tprotoc --gogo_out=paths=source_relative:. inputs/x.proto\n\t# generate ./inputs/x.pb.go\n\n## Generated code ##\n\nThe package comment for the proto library contains text describing\nthe interface provided in Go for protocol buffers. Here is an edited\nversion.\n\nIf you are using any gogo.proto extensions you will need to specify the\nproto_path to include the descriptor.proto and gogo.proto.\ngogo.proto is located in github.com/gogo/protobuf/gogoproto\nThis should be fine, since your import is the same.\ndescriptor.proto is located in either github.com/gogo/protobuf/protobuf\nor code.google.com/p/protobuf/trunk/src/\nIts import is google/protobuf/descriptor.proto so it might need some help.\n\n\tprotoc --gogo_out=. -I=.:github.com/gogo/protobuf/protobuf *.proto\n\n==========\n\nThe proto package converts data structures to and from the\nwire format of protocol buffers.  It works in concert with the\nGo source code generated for .proto files by the protocol compiler.\n\nA summary of the properties of the protocol buffer interface\nfor a protocol buffer variable v:\n\n  - Names are turned from camel_case to CamelCase for export.\n  - There are no methods on v to set fields; just treat\n  \tthem as structure fields.\n  - There are getters that return a field's value if set,\n\tand return the field's default value if unset.\n\tThe getters work even if the receiver is a nil message.\n  - The zero value for a struct is its correct initialization state.\n\tAll desired fields must be set before marshaling.\n  - A Reset() method will restore a protobuf struct to its zero state.\n  - Non-repeated fields are pointers to the values; nil means unset.\n\tThat is, optional or required field int32 f becomes F *int32.\n  - Repeated fields are slices.\n  - Helper functions are available to aid the setting of fields.\n\tHelpers for getting values are superseded by the\n\tGetFoo methods and their use is deprecated.\n\t\tmsg.Foo = proto.String(\"hello\") // set field\n  - Constants are defined to hold the default values of all fields that\n\thave them.  They have the form Default_StructName_FieldName.\n\tBecause the getter methods handle defaulted values,\n\tdirect use of these constants should be rare.\n  - Enums are given type names and maps from names to values.\n\tEnum values are prefixed with the enum's type name. Enum types have\n\ta String method, and a Enum method to assist in message construction.\n  - Nested groups and enums have type names prefixed with the name of\n  \tthe surrounding message type.\n  - Extensions are given descriptor names that start with E_,\n\tfollowed by an underscore-delimited list of the nested messages\n\tthat contain it (if any) followed by the CamelCased name of the\n\textension field itself.  HasExtension, ClearExtension, GetExtension\n\tand SetExtension are functions for manipulating extensions.\n  - Oneof field sets are given a single field in their message,\n\twith distinguished wrapper types for each possible field value.\n  - Marshal and Unmarshal are functions to encode and decode the wire format.\n\nWhen the .proto file specifies `syntax=\"proto3\"`, there are some differences:\n\n  - Non-repeated fields of non-message type are values instead of pointers.\n  - Enum types do not get an Enum method.\n\nConsider file test.proto, containing\n\n```proto\n\tsyntax = \"proto2\";\n\tpackage example;\n\n\tenum FOO { X = 17; };\n\n\tmessage Test {\n\t  required string label = 1;\n\t  optional int32 type = 2 [default=77];\n\t  repeated int64 reps = 3;\n\t}\n```\n\nTo create and play with a Test object from the example package,\n\n```go\n\tpackage main\n\n\timport (\n\t\t\"log\"\n\n\t\t\"github.com/gogo/protobuf/proto\"\n\t\t\"path/to/example\"\n\t)\n\n\tfunc main() {\n\t\ttest := \u0026example.Test{\n\t\t\tLabel: proto.String(\"hello\"),\n\t\t\tType:  proto.Int32(17),\n\t\t\tReps:  []int64{1, 2, 3},\n\t\t}\n\t\tdata, err := proto.Marshal(test)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"marshaling error: \", err)\n\t\t}\n\t\tnewTest := \u0026example.Test{}\n\t\terr = proto.Unmarshal(data, newTest)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"unmarshaling error: \", err)\n\t\t}\n\t\t// Now test and newTest contain the same data.\n\t\tif test.GetLabel() != newTest.GetLabel() {\n\t\t\tlog.Fatalf(\"data mismatch %q != %q\", test.GetLabel(), newTest.GetLabel())\n\t\t}\n\t\t// etc.\n\t}\n```\n\n\n## Parameters ##\n\nTo pass extra parameters to the plugin, use a comma-separated\nparameter list separated from the output directory by a colon:\n\n\n\tprotoc --gogo_out=plugins=grpc,import_path=mypackage:. *.proto\n\n- `paths=(import | source_relative)` - specifies how the paths of\n  generated files are structured. See the \"Packages and imports paths\"\n  section above. The default is `import`.\n- `plugins=plugin1+plugin2` - specifies the list of sub-plugins to\n  load. The only plugin in this repo is `grpc`.\n- `Mfoo/bar.proto=quux/shme` - declares that foo/bar.proto is\n  associated with Go package quux/shme.  This is subject to the\n  import_prefix parameter.\n\nThe following parameters are deprecated and should not be used:\n\n- `import_prefix=xxx` - a prefix that is added onto the beginning of\n  all imports.\n- `import_path=foo/bar` - used as the package if no input files\n  declare `go_package`. If it contains slashes, everything up to the\n  rightmost slash is ignored.\n\n## gRPC Support ##\n\nIf a proto file specifies RPC services, protoc-gen-go can be instructed to\ngenerate code compatible with gRPC (http://www.grpc.io/). To do this, pass\nthe `plugins` parameter to protoc-gen-go; the usual way is to insert it into\nthe --go_out argument to protoc:\n\n\tprotoc --gogo_out=plugins=grpc:. *.proto\n\n## Compatibility ##\n\nThe library and the generated code are expected to be stable over time.\nHowever, we reserve the right to make breaking changes without notice for the\nfollowing reasons:\n\n- Security. A security issue in the specification or implementation may come to\n  light whose resolution requires breaking compatibility. We reserve the right\n  to address such security issues.\n- Unspecified behavior.  There are some aspects of the Protocol Buffers\n  specification that are undefined.  Programs that depend on such unspecified\n  behavior may break in future releases.\n- Specification errors or changes. If it becomes necessary to address an\n  inconsistency, incompleteness, or change in the Protocol Buffers\n  specification, resolving the issue could affect the meaning or legality of\n  existing programs.  We reserve the right to address such issues, including\n  updating the implementations.\n- Bugs.  If the library has a bug that violates the specification, a program\n  that depends on the buggy behavior may break if the bug is fixed.  We reserve\n  the right to fix such bugs.\n- Adding methods or fields to generated structs.  These may conflict with field\n  names that already exist in a schema, causing applications to break.  When the\n  code generator encounters a field in the schema that would collide with a\n  generated field or method name, the code generator will append an underscore\n  to the generated field or method name.\n- Adding, removing, or changing methods or fields in generated structs that\n  start with `XXX`.  These parts of the generated code are exported out of\n  necessity, but should not be considered part of the public API.\n- Adding, removing, or changing unexported symbols in generated code.\n\nAny breaking changes outside of these will be announced 6 months in advance to\nprotobuf@googlegroups.com.\n\nYou should, whenever possible, use generated code created by the `protoc-gen-go`\ntool built at the same commit as the `proto` package.  The `proto` package\ndeclares package-level constants in the form `ProtoPackageIsVersionX`.\nApplication code and generated code may depend on one of these constants to\nensure that compilation will fail if the available version of the proto library\nis too old.  Whenever we make a change to the generated code that requires newer\nlibrary support, in the same commit we will increment the version number of the\ngenerated code and declare a new package-level constant whose name incorporates\nthe latest version number.  Removing a compatibility constant is considered a\nbreaking change and would be subject to the announcement policy stated above.\n\nThe `protoc-gen-go/generator` package exposes a plugin interface,\nwhich is used by the gRPC code generation. This interface is not\nsupported and is subject to incompatible changes without notice.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoGo%2Fprotobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGoGo%2Fprotobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoGo%2Fprotobuf/lists"}