package module
v1.0.1 Latest Latest

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 7 Imported by: 2,130



Build Status


A Go package for managing the registration, marshaling, and unmarshaling of encoded types.

This package helps when types are sent over a GRPC API and marshaled as a protobuf.Any.

Project details

typeurl is a containerd sub-project, licensed under the Apache 2.0 license. As a containerd sub-project, you will find the:

information in our containerd/project repository.




This section is empty.


View Source
var ErrNotFound = errors.New("not found")


func Is

func Is(any *types.Any, v interface{}) bool

Is returns true if the type of the Any is the same as v.

func MarshalAny

func MarshalAny(v interface{}) (*types.Any, error)

MarshalAny marshals the value v into an any with the correct TypeUrl. If the provided object is already a proto.Any message, then it will be returned verbatim. If it is of type proto.Message, it will be marshaled as a protocol buffer. Otherwise, the object will be marshaled to json.

func Register

func Register(v interface{}, args ...string)

Register a type with a base URL for JSON marshaling. When the MarshalAny and UnmarshalAny functions are called they will treat the Any type value as JSON. To use protocol buffers for handling the Any value the proto.Register function should be used instead of this function.

func TypeURL

func TypeURL(v interface{}) (string, error)

TypeURL returns the type url for a registered type.

func UnmarshalAny

func UnmarshalAny(any *types.Any) (interface{}, error)

UnmarshalAny unmarshals the any type into a concrete type.

func UnmarshalByTypeURL added in v1.0.1

func UnmarshalByTypeURL(typeURL string, value []byte) (interface{}, error)

func UnmarshalTo added in v1.0.1

func UnmarshalTo(any *types.Any, out interface{}) error

func UnmarshalToByTypeURL added in v1.0.1

func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error


This section is empty.

Jump to

Keyboard shortcuts

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