person

package
v0.0.0-...-f56171f Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Example
input := []byte{
	// message kind: Person V2
	1,
	// age
	0, 21,
	// siblings
	0, 3,
	// len of name +1
	5,
	// name
	'J', 'a', 'n', 'e',
	// junk, e.g. the next message
	'x', 'y', 'z', 'z', 'y',
}
msg, err := person.NewMyProtocolView(input)
if err != nil {
	log.Fatal(err)
}
switch view := msg.(type) {
case *person.PersonV2View:
	fmt.Printf("%q is %d years old.\n", view.Name(), view.Age())
default:
	log.Fatalf("unknown message type: %T", msg)
}
Output:

"Jane" is 21 years old.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MyProtocolMessage

type MyProtocolMessage interface {
	// contains filtered or unexported methods
}

func NewMyProtocolView

func NewMyProtocolView(data []byte) (MyProtocolMessage, error)

type PersonV2View

type PersonV2View struct {
	// contains filtered or unexported fields
}

func NewPersonV2View

func NewPersonV2View(data []byte) (*PersonV2View, error)

func (*PersonV2View) Age

func (v *PersonV2View) Age() uint16

func (*PersonV2View) Name

func (v *PersonV2View) Name() string

Name returns a view of the name. Caller must not keep references to it past the lifetime of the view.

If the message is truncated, returns an empty string.

func (*PersonV2View) Siblings

func (v *PersonV2View) Siblings() uint16

Jump to

Keyboard shortcuts

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