etcdexample

package
v0.0.0-...-d0f0867 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: Apache-2.0 Imports: 1 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 --gogo_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.

Package etcdexample is a generated protocol buffer package.

It is generated from these files:

example.proto

It has these top-level messages:

EtcdExample

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EtcdExample

type EtcdExample struct {
	StringVal string `protobuf:"bytes,1,opt,name=string_val,proto3" json:"string_val,omitempty"`
	Uint32Val uint32 `protobuf:"varint,2,opt,name=uint32_val,proto3" json:"uint32_val,omitempty"`
	BoolVal   bool   `protobuf:"varint,3,opt,name=bool_val,proto3" json:"bool_val,omitempty"`
}

func (*EtcdExample) ProtoMessage

func (*EtcdExample) ProtoMessage()

func (*EtcdExample) Reset

func (pb *EtcdExample) Reset()

func (*EtcdExample) String

func (pb *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"`
}

func (*EtcdExampleStructExample) ProtoMessage

func (*EtcdExampleStructExample) ProtoMessage()

func (*EtcdExampleStructExample) Reset

func (m *EtcdExampleStructExample) Reset()

func (*EtcdExampleStructExample) String

func (m *EtcdExampleStructExample) String() string

Jump to

Keyboard shortcuts

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