stdtype

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatEface added in v0.2.1

func FormatEface(typ *abi.Type, data unsafe.Pointer) any

func FormatIface added in v0.2.1

func FormatIface[T any](itab *abi.Itab, data unsafe.Pointer) T

NOTE: T MUST be an interface type with at least one method.

func FromEface added in v0.2.1

func FromEface(ep *Eface) any

func FromIface added in v0.2.1

func FromIface[T any](ip *Iface) T

NOTE: T MUST be an interface type with at least one method.

func Type added in v0.2.1

func Type[T any]() *abi.Type

func TypeOf

func TypeOf(x any) *abi.Type

TypeOf returns the runtime type of x.

func ValueOf added in v0.2.1

func ValueOf(x any) unsafe.Pointer

ValueOf returns the data in x.

Types

type Eface

type Eface struct {
	Type *abi.Type
	Data unsafe.Pointer
}

Eface is the definition for interfaces with no method.

  • interface{}
  • any
  • type Foo interface{}

func EfaceOf

func EfaceOf(ep *any) *Eface

EfaceOf returns the underlay Eface data of *ep.

type Iface

type Iface struct {
	Itab *abi.Itab
	Data unsafe.Pointer
}

Iface is the definition for interfaces with at least one method.

func IfaceOf

func IfaceOf[T any](ip *T) *Iface

IfaceOf returns the underlay Iface data of T.

NOTE: T MUST be an interface type with at least one method.

type TypeAssertionError

type TypeAssertionError struct {
	Interface     *abi.Type
	Concrete      *abi.Type
	Asserted      *abi.Type
	MissingMethod string // one method needed by Interface, missing from Concrete
}

A TypeAssertionError explains a failed type assertion.

func (*TypeAssertionError) WriteErr

func (e *TypeAssertionError) WriteErr(w cerr.Writer) int

WriteErr implements cerr.E

Jump to

Keyboard shortcuts

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