generators

package
v0.0.0-...-ba52af2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func FormatCode

func FormatCode(path string) error

FormatCode runs gofmt on the generated file

func GenerateFile

func GenerateFile(tmplContent string, data interface{}, outputPath string) error

GenerateFile creates a file from a template

func Pluralize

func Pluralize(s string) string

Pluralize attempts to pluralize a word (basic rules)

func Singularize

func Singularize(s string) string

Singularize attempts to singularize a word (basic rules)

func ToCamel

func ToCamel(s string) string

ToCamel converts string to CamelCase

func ToKebab

func ToKebab(s string) string

ToKebab converts string to kebab-case

func ToPackage

func ToPackage(s string) string

ToPackage converts string to a safe Go package name

func ToSnake

func ToSnake(s string) string

ToSnake converts string to snake_case

func ToTitle

func ToTitle(s string) string

ToTitle converts string to Title Case

Types

type Field

type Field struct {
	Name     string
	Type     string
	Tag      string
	Default  string
	Nullable bool
}

Field represents a model field for generation

func ParseFields

func ParseFields(args []string) []Field

ParseFields parses field definitions from args Format: name:type name:type:nullable

type NameVariants

type NameVariants struct {
	Original string // As provided by user
	Snake    string // snake_case
	Camel    string // CamelCase
	Lower    string // lowercase
	Upper    string // UPPERCASE
	Kebab    string // kebab-case
	Plural   string // pluralized snake_case
	Singular string // singularized snake_case
	Title    string // Title Case
	Package  string // package safe name
}

NameVariants holds different case variations of a name

func NewNameVariants

func NewNameVariants(name string) *NameVariants

NewNameVariants creates all name variations from input

Jump to

Keyboard shortcuts

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