etcdexample

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

Protobuf Messages and Go Data Structures

The Agent build tools support easy integration of protobuf data format definitions into your program.

  1. Define your data formats as a set of messages in a google protobuf file. For a simple example, see examples/model/example.proto.
  2. In the plugin's main file (for example, etcd/main.go), add the following line at the top of the file:
  // go:generate protoc --proto_path=examples/model --go_out=examples/model examples/model/example.proto
  1. You can have multiple files with protobuf message definitions. Add a similar line for each file.
  2. The above line will instruct the go tool to use the protoc code generator to generate go structures from protobuf messages defined in the example.proto file. The line also specifies the path to the file and the location where to put the generated structures (in our example, all are the same, examples/model).
  3. Do make generate to generate go structures from protobuf message definitions. The structures will be put into example.pb.go in the same folder. The structures will be annotated with protobuf annotations to support marshalling/un-marshalling at run-time.

You can now use the generated go structures in your code.

Documentation

Overview

Package etcdexample explains how to generate Golang structures from protobuf-formatted data.

Index

Constants

This section is empty.

Variables

View Source
var File_example_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type EtcdExample

type EtcdExample struct {
	StringVal string `protobuf:"bytes,1,opt,name=string_val,json=stringVal,proto3" json:"string_val,omitempty"`  // Example of a string value
	Uint32Val uint32 `protobuf:"varint,2,opt,name=uint32_val,json=uint32Val,proto3" json:"uint32_val,omitempty"` // Example of a uint32 value
	BoolVal   bool   `protobuf:"varint,3,opt,name=bool_val,json=boolVal,proto3" json:"bool_val,omitempty"`       // Example of a bool value
	// contains filtered or unexported fields
}

func (*EtcdExample) Descriptor deprecated

func (*EtcdExample) Descriptor() ([]byte, []int)

Deprecated: Use EtcdExample.ProtoReflect.Descriptor instead.

func (*EtcdExample) GetBoolVal

func (x *EtcdExample) GetBoolVal() bool

func (*EtcdExample) GetStringVal

func (x *EtcdExample) GetStringVal() string

func (*EtcdExample) GetUint32Val

func (x *EtcdExample) GetUint32Val() uint32

func (*EtcdExample) ProtoMessage

func (*EtcdExample) ProtoMessage()

func (*EtcdExample) ProtoReflect

func (x *EtcdExample) ProtoReflect() protoreflect.Message

func (*EtcdExample) Reset

func (x *EtcdExample) Reset()

func (*EtcdExample) String

func (x *EtcdExample) String() string

type EtcdExampleStructExample

type EtcdExampleStructExample struct {
	Val1 string `protobuf:"bytes,1,opt,name=val1,proto3" json:"val1,omitempty"`
	Val2 uint32 `protobuf:"varint,2,opt,name=val2,proto3" json:"val2,omitempty"`
	// contains filtered or unexported fields
}

func (*EtcdExampleStructExample) Descriptor deprecated

func (*EtcdExampleStructExample) Descriptor() ([]byte, []int)

Deprecated: Use EtcdExampleStructExample.ProtoReflect.Descriptor instead.

func (*EtcdExampleStructExample) GetVal1

func (x *EtcdExampleStructExample) GetVal1() string

func (*EtcdExampleStructExample) GetVal2

func (x *EtcdExampleStructExample) GetVal2() uint32

func (*EtcdExampleStructExample) ProtoMessage

func (*EtcdExampleStructExample) ProtoMessage()

func (*EtcdExampleStructExample) ProtoReflect

func (x *EtcdExampleStructExample) ProtoReflect() protoreflect.Message

func (*EtcdExampleStructExample) Reset

func (x *EtcdExampleStructExample) Reset()

func (*EtcdExampleStructExample) String

func (x *EtcdExampleStructExample) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL