parser

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StructField

type StructField struct {
	// The field's raw name
	Name string

	// The value of the json tag if provided, defaults to field name otherwise
	JSONKey string

	// Whether or not this field has been tagged as batchable
	Batchable bool

	// If this field is a struct, it will have nested fields inside. SubFields holds those nested fields.
	SubFields []StructField

	TypeInfo TypeInfo
}

type StructInfo

type StructInfo struct {
	Package string
	Name    string
	Fields  []StructField
}

func ParseStruct

func ParseStruct(pkgPath, structName string) (*StructInfo, error)

ParseStruct walks the pkgPath to gather all type declarations and then compares type names to structName to find the target struct, returning it's fields (and subfields if any exist) as a StructInfo.

type TypeInfo

type TypeInfo struct {
	// The field's type, for example "[]*Item"
	TypeString string

	// If this type represents a slice, this stores the internal element type. For example "*Item"
	ElemType string

	// True if this type is a scalar (e.g. not a struct).
	IsScalar bool
}

Jump to

Keyboard shortcuts

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