example

package module
v0.0.0-...-5b229e5 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

Go Protobuf OneOf JSON

This project illustrates the issue that occurs when marshalling a protobuf object to JSON when that object has a field that's an array and the elements of the array utilize OneOf.

Getting Started

To illustrate the issue, run the following command:

$ go get github.com/akutz/go-proto-oneof-json && \
  go test -v github.com/akutz/go-proto-oneof-json

Documentation

Overview

Package example is a generated protocol buffer package.

It is generated from these files:

example.proto

It has these top-level messages:

Parent
Dependent
CreateDependencyRequest
CreateDependencyResponse

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFamilyServer

func RegisterFamilyServer(s *grpc.Server, srv FamilyServer)

Types

type CreateDependencyRequest

type CreateDependencyRequest struct {
	ParentName string       `protobuf:"bytes,1,opt,name=parent_name,json=parentName" json:"parent_name,omitempty"`
	Dependents []*Dependent `protobuf:"bytes,2,rep,name=dependents" json:"dependents,omitempty"`
}

func (*CreateDependencyRequest) Descriptor

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

func (*CreateDependencyRequest) GetDependents

func (m *CreateDependencyRequest) GetDependents() []*Dependent

func (*CreateDependencyRequest) GetParentName

func (m *CreateDependencyRequest) GetParentName() string

func (*CreateDependencyRequest) ProtoMessage

func (*CreateDependencyRequest) ProtoMessage()

func (*CreateDependencyRequest) Reset

func (m *CreateDependencyRequest) Reset()

func (*CreateDependencyRequest) String

func (m *CreateDependencyRequest) String() string

type CreateDependencyResponse

type CreateDependencyResponse struct {
}

func (*CreateDependencyResponse) Descriptor

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

func (*CreateDependencyResponse) ProtoMessage

func (*CreateDependencyResponse) ProtoMessage()

func (*CreateDependencyResponse) Reset

func (m *CreateDependencyResponse) Reset()

func (*CreateDependencyResponse) String

func (m *CreateDependencyResponse) String() string

type Dependent

type Dependent struct {
	// Types that are valid to be assigned to Child:
	//	*Dependent_Son
	//	*Dependent_Daughter
	Child isDependent_Child `protobuf_oneof:"child"`
	Name  string            `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
}

func (*Dependent) Descriptor

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

func (*Dependent) GetChild

func (m *Dependent) GetChild() isDependent_Child

func (*Dependent) GetDaughter

func (m *Dependent) GetDaughter() *Dependent_Female

func (*Dependent) GetName

func (m *Dependent) GetName() string

func (*Dependent) GetSon

func (m *Dependent) GetSon() *Dependent_Male

func (*Dependent) ProtoMessage

func (*Dependent) ProtoMessage()

func (*Dependent) Reset

func (m *Dependent) Reset()

func (*Dependent) String

func (m *Dependent) String() string

func (*Dependent) XXX_OneofFuncs

func (*Dependent) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type Dependent_Daughter

type Dependent_Daughter struct {
	Daughter *Dependent_Female `protobuf:"bytes,2,opt,name=daughter,oneof"`
}

type Dependent_Female

type Dependent_Female struct {
	Attributes []string `protobuf:"bytes,1,rep,name=attributes" json:"attributes,omitempty"`
}

func (*Dependent_Female) Descriptor

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

func (*Dependent_Female) GetAttributes

func (m *Dependent_Female) GetAttributes() []string

func (*Dependent_Female) ProtoMessage

func (*Dependent_Female) ProtoMessage()

func (*Dependent_Female) Reset

func (m *Dependent_Female) Reset()

func (*Dependent_Female) String

func (m *Dependent_Female) String() string

type Dependent_Male

type Dependent_Male struct {
}

func (*Dependent_Male) Descriptor

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

func (*Dependent_Male) ProtoMessage

func (*Dependent_Male) ProtoMessage()

func (*Dependent_Male) Reset

func (m *Dependent_Male) Reset()

func (*Dependent_Male) String

func (m *Dependent_Male) String() string

type Dependent_Son

type Dependent_Son struct {
	Son *Dependent_Male `protobuf:"bytes,1,opt,name=son,oneof"`
}

type FamilyClient

type FamilyClient interface {
	CreateDependency(ctx context.Context, in *CreateDependencyRequest, opts ...grpc.CallOption) (*CreateDependencyResponse, error)
}

func NewFamilyClient

func NewFamilyClient(cc *grpc.ClientConn) FamilyClient

type FamilyServer

type FamilyServer interface {
	CreateDependency(context.Context, *CreateDependencyRequest) (*CreateDependencyResponse, error)
}

type Parent

type Parent struct {
	Name       string       `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	Dependents []*Dependent `protobuf:"bytes,2,rep,name=dependents" json:"dependents,omitempty"`
}

func (*Parent) Descriptor

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

func (*Parent) GetDependents

func (m *Parent) GetDependents() []*Dependent

func (*Parent) GetName

func (m *Parent) GetName() string

func (*Parent) ProtoMessage

func (*Parent) ProtoMessage()

func (*Parent) Reset

func (m *Parent) Reset()

func (*Parent) String

func (m *Parent) String() string

Jump to

Keyboard shortcuts

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