example

package
v0.0.0-...-ab86bc2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

Examples

Generate code

First, generate necessary structures using

go generate ./...

Basic examples

1 Person per file

go run ./basic < customer.bin
go run ./basic < exmployee.bin
go run ./basic < terminated.bin

Stream example

Multiple people in a single file or stream

go run ./stream < people.bin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Address [4]string `bare:"address"`
	City    string    `bare:"city"`
	State   string    `bare:"state"`
	Country string    `bare:"country"`
}

func (*Address) Decode

func (t *Address) Decode(data []byte) error

func (*Address) Encode

func (t *Address) Encode() ([]byte, error)

type Customer

type Customer struct {
	Name    string  `bare:"name"`
	Email   string  `bare:"email"`
	Address Address `bare:"address"`
	Orders  []struct {
		OrderId  int64 `bare:"orderId"`
		Quantity int32 `bare:"quantity"`
	} `bare:"orders"`
	Metadata map[string][]byte `bare:"metadata"`
}

func (*Customer) Decode

func (t *Customer) Decode(data []byte) error

func (*Customer) Encode

func (t *Customer) Encode() ([]byte, error)

func (Customer) IsUnion

func (_ Customer) IsUnion()

type Department

type Department uint
const (
	ACCOUNTING       Department = 0
	ADMINISTRATION   Department = 1
	CUSTOMER_SERVICE Department = 2
	DEVELOPMENT      Department = 3
	JSMITH           Department = 99
)

func (Department) String

func (t Department) String() string

type Employee

type Employee struct {
	Name       string            `bare:"name"`
	Email      string            `bare:"email"`
	Address    Address           `bare:"address"`
	Department Department        `bare:"department"`
	HireDate   Time              `bare:"hireDate"`
	PublicKey  *PublicKey        `bare:"publicKey"`
	Metadata   map[string][]byte `bare:"metadata"`
}

func (*Employee) Decode

func (t *Employee) Decode(data []byte) error

func (*Employee) Encode

func (t *Employee) Encode() ([]byte, error)

func (Employee) IsUnion

func (_ Employee) IsUnion()

type Person

type Person interface {
	bare.Union
}

type PublicKey

type PublicKey [128]byte

func (*PublicKey) Decode

func (t *PublicKey) Decode(data []byte) error

func (*PublicKey) Encode

func (t *PublicKey) Encode() ([]byte, error)

type TerminatedEmployee

type TerminatedEmployee struct{}

func (*TerminatedEmployee) Decode

func (t *TerminatedEmployee) Decode(data []byte) error

func (*TerminatedEmployee) Encode

func (t *TerminatedEmployee) Encode() ([]byte, error)

func (TerminatedEmployee) IsUnion

func (_ TerminatedEmployee) IsUnion()

type Time

type Time time.Time

func (*Time) Unmarshal

func (t *Time) Unmarshal(r *bare.Reader) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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