ast

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildImportMap

func BuildImportMap(file *goast.File) map[string]string

BuildImportMap returns a map from each import's local name (explicit alias or inferred last path segment) to its full import path. Blank ("_") and dot (".") imports are excluded.

func FilterModuleImports

func FilterModuleImports(imports map[string]string, modulePath string) map[string]string

FilterModuleImports filters an import map to only include module-internal imports and converts the values from full import paths to module-relative directory paths.

func GetModulePath

func GetModulePath(dir string) (string, error)

GetModulePath reads the module path from the go.mod file in the given directory.

func GetStructFields

func GetStructFields(structType *goast.StructType) map[string]string

GetStructFields returns a map of field names to their type representation from an *ast.StructType. Fields named "_" are excluded. Type representations: "TypeName" for local types, "pkg.TypeName" for imported types.

func GetTagValue

func GetTagValue(tag, key string) string

GetTagValue extracts the value of a specific tag key from a raw struct field tag string (with or without surrounding backticks). It returns the value before any comma (i.e., omitting options like "omitempty"), with surrounding quotes stripped. Returns empty string if the key is not found.

Types

This section is empty.

Jump to

Keyboard shortcuts

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