parser

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGORMServices

func GenerateGORMServices(cfg *config.Config, structMetaData []StructMeta) (err error)

generateServices generates the service.go file

func GetModulePath

func GetModulePath(targetDir string) (string, error)

Returns the go import path for a given directory targetDir

func GetPreloadMap

func GetPreloadMap(structs []StructMeta, cfg *config.Config) map[string][]string

GetPreloadMap returns a map of struct names to their respective preload fields, including nested relationships.

func Map

func Map(data []StructMeta) (m map[string]StructMeta)

Create a StructMeta map from slice.

Types

type Field

type Field struct {
	Name     string // Field Exact name
	Type     string // Full data type for the field
	BaseType string // Base type stripped of [] or pointers
	Tag      string // Unmodified struct tag.
	Preload  bool   // Whether this is a foreignKey or many2many field to preload.
	Parent   string // Parent struct Name
}

Field contains meta-data for each struct field.

type StructMeta

type StructMeta struct {
	Name    string  // Model name e.g User
	PKType  string  // PKType e.g int, int64 etc
	Fields  []Field // Fields for struct fields that are builtin(only)
	Package string  // Package name e.g "github.com/username/module/models"
	Skip    bool    // Skip generating service for this struct
}

StructMeta contains metadata about the struct generated by the go/ast.

func Parse

func Parse(modelPkgs []string) []StructMeta

Parse structs in package pkg and return Struct metadata about them.

Jump to

Keyboard shortcuts

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