utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PluralizeClient *pluralize.Client

Functions

func AddImport

func AddImport(content []byte, importStr string) ([]byte, bool)

func AddModuleInitializer

func AddModuleInitializer(content []byte, packageName, singularName string) ([]byte, bool)

func GenerateAirFileFromTemplate

func GenerateAirFileFromTemplate(dir string) error

GenerateAirFileFromTemplate generates the air.toml configuration file from template

func GenerateFileFromTemplate

func GenerateFileFromTemplate(dir, filename, templateName, structName, pluralName, packageName string, fields []FieldStruct)

GenerateFileFromTemplate generates a file from a template

func GetGoType

func GetGoType(t string) string

func GetRequiredImports

func GetRequiredImports(fields []FieldStruct) map[string][]string

func HasFieldType

func HasFieldType(fields []FieldStruct, fieldType string) bool

HasFieldType checks if any field has the specified type

func HasImageField

func HasImageField(fields []FieldStruct) bool

HasImageField checks if any field has the image type

func RemoveImport

func RemoveImport(content []byte, importStr string) []byte

func RemoveModuleInitializer

func RemoveModuleInitializer(content []byte, pluralName string) []byte

func ToCamelCase

func ToCamelCase(s string) string

func ToKebabCase

func ToKebabCase(s string) string

func ToLower

func ToLower(s string) string

func ToLowerPlural

func ToLowerPlural(s string) string

func ToPascalCase

func ToPascalCase(s string) string

func ToPlural

func ToPlural(s string) string

func ToSnakeCase

func ToSnakeCase(s string) string

func ToTitle

func ToTitle(s string) string

func Unzip

func Unzip(src, dest string) error

Unzip extracts a zip archive to a destination directory.

func UpdateInitFile

func UpdateInitFile(singularName, pluralName string) error

func UpdateInitFileForDestroy

func UpdateInitFileForDestroy(singularName string) error

func UpdateInitGo

func UpdateInitGo(packageName, structName string) error

UpdateInitGo adds the module initialization to init.go

Types

type FieldStruct

type FieldStruct struct {
	Name            string
	Type            string
	JSONName        string
	DBName          string
	AssociatedType  string
	AssociatedTable string
	PluralType      string
	Relationship    string
	RelatedModel    string
	IsRequired      bool
	GORM            string // Add this field for GORM tags

}

FieldStruct represents a field in the model

func GenerateFieldStructs

func GenerateFieldStructs(fields []string) []FieldStruct

GenerateFieldStructs processes all fields and returns a slice of FieldStruct

func ProcessField added in v1.1.3

func ProcessField(fieldDef string) []FieldStruct

Jump to

Keyboard shortcuts

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