types

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstValue

type ConstValue struct {
	// The constant's identifier.
	Name string
	// The value of the constant.
	Value string
	// The position of the constant's declaration in the source code.
	Pos Position
	// The raw documentation of the constant.
	Doc []string
}

ConstValue represents a typed constant.

type Kind

type Kind uint

Kind indicates the specific kind of a Go type.

const (
	// basic
	KindInvalid Kind = iota

	KindBool
	KindInt
	KindInt8
	KindInt16
	KindInt32
	KindInt64
	KindUint
	KindUint8
	KindUint16
	KindUint32
	KindUint64
	KindUintptr
	KindFloat32
	KindFloat64
	KindComplex64
	KindComplex128
	KindString
	KindUnsafePointer

	// non-basic
	KindArray
	KindInterface
	KindMap
	KindPtr // 24
	KindSlice
	KindStruct

	// not supported
	KindChan
	KindFunc

	// alisases (basic)
	KindByte = KindUint8
	KindRune = KindInt32
)

func (Kind) IsBasic

func (k Kind) IsBasic() bool

Reports whether or not k is of a basic kind.

func (Kind) String

func (k Kind) String() string

type Position

type Position struct {
	// The name of the file in the token is declared.
	Filename string `cmp:"+"`
	// The line at which the token is declared in the file.
	Line int `cmp:"+"`
}

The position of a token in the source code.

func (Position) IsZero

func (p Position) IsZero() bool

IsZero reports whether or not p is empty.

type Source

type Source struct {
	// contains filtered or unexported fields
}

not safe for concurrency

func Load

func Load(dir string) (*Source, error)

func (*Source) TypeDeclOf

func (s *Source) TypeDeclOf(v interface{}) *TypeDecl

func (*Source) TypeOf

func (s *Source) TypeOf(v interface{}) *Type

type StructField

type StructField struct {
	// Name of the field.
	Name string
	// The field's type.
	Type *Type
	// The field's raw tag.
	Tag string
	// Indicates whether or not the field is embedded.
	IsEmbedded bool
	// Indicates whether or not the field is exported.
	IsExported bool
	// The position of the field's declaration in the source code.
	Pos Position
	// The raw documentation of a struct field.
	Doc []string
}

StructField describes a single struct field.

type Type

type Type struct {
	// The position of the type's declaration in the source code.
	Pos Position
	// The raw documentation of a named type.
	Doc []string
	// The name of a named type or empty string for unnamed types
	Name string
	// The kind of the go type.
	Kind Kind
	// The package import path.
	PkgPath string
	// Indicates whether or not the type is the "byte" alias type.
	IsByte bool
	// Indicates whether or not the type is the "rune" alias type.
	IsRune bool
	// If the base type's an array type, this field will hold the array's length.
	ArrayLen int
	// If kind is map, key will hold the info on the map's key type.
	Key *Type
	// If kind is map, elem will hold the info on the map's value type.
	// If kind is ptr, elem will hold the info on pointed-to type.
	// If kind is slice/array, elem will hold the info on slice/array element type.
	// If kind is interface and the analyzed value was valid, elem will hold
	// the info on the dynamic type.
	Elem *Type
	// If kind is struct, Fields will hold the list of the struct's fields.
	Fields []*StructField
	// If Type is a basic, defined type then Values will hold the list of
	// declared constants of that type, if any.
	Values []*ConstValue
	// NOTE: Set only for types of the struct kind.
	ReflectType reflect.Type
	// contains filtered or unexported fields
}

Type is the representation of a Go type.

func (*Type) CanSelectFields

func (t *Type) CanSelectFields() bool

CanSelectFields reports whether a value of Type t can be used in a field selector expression.

func (*Type) String

func (t *Type) String() string

type TypeDecl

type TypeDecl struct {
	// The position of a type's declaration in the source code.
	Pos Position
	// The raw documentation of the type.
	Doc []string
	// The declared type's name
	Name string
	// The type's package import path
	PkgPath string
}

TypeDecl holds basic info on a declared Go type.

Jump to

Keyboard shortcuts

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