types

package
v0.0.0-...-150c41c Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package types contains utils to work with types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindExternalTypes

func FindExternalTypes(pkgsTypes slices.Sorted[*Type], taggedStructs ast.TaggedStructs) slices.Sorted[ExternalType]

FindExternalTypes finds all external types in the given list of types.

func FindPkgDecls

func FindPkgDecls(taggedStructs ast.TaggedStructs, loadedPkgs []*packages.Package) (slices.Sorted[*PkgDecl], error)

FindPkgDecls finds all declarations in the given packages.

func MatchTypeData

func MatchTypeData[T Basic | Complex | Map | Slice](d TypeInfoData) (T, bool)

MatchTypeData matches the given TypeInfoData to the given type.

func ParseDeclsData

func ParseDeclsData(sortedPkgs slices.Sorted[*PkgDecl], taggedStructs ast.TaggedStructs) (slices.Sorted[*Type], error)

ParseDeclsData parses all declarations and returns a list of packages with proper types.

Types

type Basic

type Basic struct {
	Name string
	Pkg  string
}

Basic is a basic type.

type Complex

type Complex struct {
	Name string
	Pkg  string
}

Complex is a complex type.

type ExternalType

type ExternalType struct {
	Pkg  string
	Name string
}

ExternalType is a struct which contains external type pkg and name.

func (ExternalType) String

func (e ExternalType) String() string

String returns a string representation of the ExternalType.

type FieldData

type FieldData struct {
	Name     string
	Num      int
	TypeData *types.Var
}

FieldData is a struct which contains field name, proto num and type data.

type Map

type Map struct {
	KeyTypeName string
	KeyTypePkg  string

	ElemTypeName string
	ElemTypePkg  string
}

Map is a map type.

type PkgDecl

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

PkgDecl is a struct which contains package path and tagged struct declarations.

type Slice

type Slice struct {
	Name      string
	Pkg       string
	Is2DSlice bool
}

Slice is a slice type.

type Type

type Type struct {
	Pkg      string
	Name     string
	Comments []string
	// contains filtered or unexported fields
}

Type is a struct which contains type pkg, name, comments and fields.

func (*Type) Fields

func (t *Type) Fields() *slices.Sorted[FieldData]

Fields returns a list of fields for the given type.

func (*Type) PkgName

func (t *Type) PkgName() string

PkgName returns a package name for the given type.

type TypeInfoData

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

TypeInfoData is a struct which contains type data.

func MakeTypeData

func MakeTypeData[T Basic | Complex | Map | Slice](v T) TypeInfoData

MakeTypeData creates a new TypeInfoData from the given type.

func TypeInfo

func TypeInfo(t types.Type) TypeInfoData

TypeInfo extracts all type data from the given type.

Jump to

Keyboard shortcuts

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