encoding

package
v1.70.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package encoding contains helpers to encode or decode values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalProtoJSON added in v1.50.0

func MarshalProtoJSON(value proto.Message) []byte

MarshalProtoJSON encode proto message into JSON.

func UnmarshalProtoJSON added in v1.50.0

func UnmarshalProtoJSON(value []byte, dest proto.Message)

UnmarshalProtoJSON decode JSON into proto message.

Types

type GobInt32

type GobInt32 int32

GobInt32 can be used as a pointer inside a struct. When serialized with encoding/gob it will differentiate between a nil pointer or a zero, which is not possible with the stdlib.

It helps us for example when transferring XML decoded data to a queue, where we need to encode the value but keep the information of which fields are present and which ones are really zero value.

func NewGobInt32

func NewGobInt32(v int32) *GobInt32

NewGobInt32 builds a new instance with the specified value. It is a comodity to build new numbers with a constant without an intermediary variable.

func (*GobInt32) GobDecode

func (v *GobInt32) GobDecode(data []byte) error

GobDecode implements the encoding/gob interface.

func (*GobInt32) GobEncode

func (v *GobInt32) GobEncode() ([]byte, error)

GobEncode implements the encoding/gob interface.

Jump to

Keyboard shortcuts

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