typeinfo

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONFieldName

func JSONFieldName(f reflect.StructField) (name string, omitEmpty bool)

JSONFieldName returns the name that the field will be given when marshaled to JSON, or the empty string if the field is ignored. It also reports whether the field has been qualified with the "omitempty" qualifier.

func ParseSchema

func ParseSchema(s string, ns *parser.Namespace) (schema.AvroType, error)

ParseSchema parses the given Avro type and resolves all its references. If ns is non-nil, it will be used as the namespace for the definitions.

Types

type Info

type Info struct {
	// Type holds the Go type used for this Avro type (or nil for null).
	Type reflect.Type

	// FieldName holds the Avro name of the field.
	FieldName string

	// FieldIndex holds the index of the field if this entry is about
	// a struct field.
	FieldIndex int

	// MakeDefault is a function that returns the default
	// value for a field, or nil if there is no default value.
	MakeDefault func() reflect.Value

	// IsUnion holds whether this info is about a union type
	// (if not, it's about a struct).
	IsUnion bool

	// Entries holds the possible types that can
	// be descended in from this type.
	// For structs (records) this holds an entry
	// for each field; for union types, this holds an
	// entry for each possible type in the union.
	Entries []Info
}

Info is the representation of Go types used by the analyzer. It can represent a record, a field or a type inside one of those.

func ForType

func ForType(t reflect.Type) (Info, error)

ForType returns the Info for the given Go type.

Jump to

Keyboard shortcuts

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