package description

import "github.com/gogo/protobuf/plugin/description"

The description (experimental) plugin generates a Description method for each message. The Description method returns a populated google_protobuf.FileDescriptorSet struct. This contains the description of the files used to generate this message.

It is enabled by the following extensions:

The description plugin also generates a test given it is enabled using one of the following extensions:

Let us look at:

github.com/gogo/protobuf/test/example/example.proto

Btw all the output can be seen at:

github.com/gogo/protobuf/test/example/*

The following message:

  message B {
	option (gogoproto.description) = true;
	optional A A = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
	repeated bytes G = 2 [(gogoproto.customtype) = "github.com/gogo/protobuf/test/custom.Uint128", (gogoproto.nullable) = false];
  }

given to the description plugin, will generate the following code:

  func (this *B) Description() (desc *google_protobuf.FileDescriptorSet) {
	return ExampleDescription()
  }

and the following test code:

  func TestDescription(t *testing9.T) {
	ExampleDescription()
  }

The hope is to use this struct in some way instead of reflect. This package is subject to change, since a use has not been figured out yet.

Index

Functions

func NewPlugin

func NewPlugin() *plugin

func NewTest

Source Files

description.go descriptiontest.go

Version
v1.3.2 (latest)
Published
Jan 10, 2021
Platform
js/wasm
Imports
8 packages
Last checked
2 days ago

Tools for package owners.