xtypes

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

README

xtypes

Package xtypes provides go/types extended utilities. Converting types.Type into reflect.Type.

ctx := xtypes.NewContext(nil)
t, err := xtypes.ToType(typ,ctx)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUntyped error
	ErrUntyped = errors.New("untyped type")
	// ErrUnknownArrayLen error
	ErrUnknownArrayLen = errors.New("unknown array length")
)

Functions

func Field added in v0.1.24

func Field(v interface{}, index int) (interface{}, error)

func FieldAddr added in v0.1.24

func FieldAddr(v interface{}, index int) (interface{}, error)

func IntuitiveMethodSet added in v0.1.11

func IntuitiveMethodSet(T types.Type) []*types.Selection

golang.org/x/tools/go/types/typeutil.IntuitiveMethodSet

func ToType

func ToType(typ types.Type, ctx Context) (reflect.Type, error)

func ToTypeList

func ToTypeList(tuple *types.Tuple, ctx Context) (list []reflect.Type, err error)

Types

type Context

type Context interface {
	FindType(typ types.Type) (reflect.Type, bool)
	FindTypeName(name *types.TypeName) (reflect.Type, bool)
	FindMethod(mtyp reflect.Type, method *types.Func) func(args []reflect.Value) []reflect.Value
	UpdateType(name *types.TypeName, typ reflect.Type, fnUpdateMethods func() error)
}

Context interface

func NewContext

func NewContext(
	findMethod func(mtyp reflect.Type, method *types.Func) func(args []reflect.Value) []reflect.Value,
	findTypeName func(name *types.TypeName) (reflect.Type, bool),
	findType func(typ types.Type) (reflect.Type, bool),
) Context

Directories

Path Synopsis
internal
reflect
Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types.
Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types.
unsafeheader
Package unsafeheader contains header declarations for the Go runtime's slice and string implementations.
Package unsafeheader contains header declarations for the Go runtime's slice and string implementations.

Jump to

Keyboard shortcuts

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