Documentation
¶
Index ¶
- func BuildImportMap(file *goast.File) map[string]string
- func FilterModuleImports(imports map[string]string, modulePath string) map[string]string
- func GetModulePath(dir string) (string, error)
- func GetStructFields(structType *goast.StructType) map[string]string
- func GetTagValue(tag, key string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildImportMap ¶
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 ¶
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 ¶
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 ¶
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.