utils

package
v0.0.0-...-1180a88 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	String  = "string"
	Error   = "error"
	Integer = "int"
	Float   = "float64"
	Boolean = "bool"
)

Variables

View Source
var TemplateFuncs = template.FuncMap(map[string]any{

	"GetServiceName": func() string { return config.GetConfig().AppConfig["AppName"] },
	"GetModuleName":  func() string { return config.GetConfig().Name },

	"ToConfigCase": func(str string) string {
		var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
		var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
		snake := matchFirstCap.ReplaceAllString(str, "${1}_${2}")
		snake = matchAllCap.ReplaceAllString(snake, "${1}_${2}")
		return strings.ToUpper(snake)
	},
	"TypeOf":           TypeOf,
	"TitleCasedTypeOf": func(str string) string { return cases.Title(language.English).String(TypeOf(str)) },
	"IsString":         func(str string) bool { return TypeOf(str) == "string" },
	"FirstToLower":     FirstToLower,
	"ToTitle":          cases.Title(language.English).String,
	"GetFirstLetter":   func(str string) string { return strings.ToLower(string(str[0])) },

	"IsLastIndexInMap":   IsLastIndexInMap[string, string],
	"IsLastIndexInSlice": IsLastIndexInSlice[string],
	"SliceContains":      slices.Contains[[]string, string],
	"IsNotEmpty":         func(array []configmodels.Service) bool { return len(array) > 0 },

	"ZeroValue":                   ZeroValue,
	"ZeroReturnValues":            ZeroReturnValues,
	"GetMethodSignatureByName":    GetMethodSignatureByName,
	"GetMethodSignatureByValue":   GetMethodSignatureByValue,
	"GetHandlerLogicMethodString": GetHandlerLogicMethodString,
	"GetServiceClass":             func(str string) string { return strings.Split(str, ".")[0] },

	"BuilderFunc": CreateBuilderFunc,
})

Functions

func CreateBuilderFunc

func CreateBuilderFunc(table configmodels.Table) string

func CreateFileForType

func CreateFileForType(fLocation FileLocation, fname string, ext FileExtension) *os.File

func CreatePathIfNotExists

func CreatePathIfNotExists(path string)

func FirstToLower

func FirstToLower(s string) string

func GetBuilderFunc

func GetBuilderFunc(table configmodels.Table) string

func GetHandlerLogicMethodString

func GetHandlerLogicMethodString(name string) string

func GetLogicMethod

func GetLogicMethod(name string) configmodels.Method

func GetMethodSignatureByName

func GetMethodSignatureByName(name string) string

func GetMethodSignatureByValue

func GetMethodSignatureByValue(name string, args datastructures.OrderedMap[string, string], returns string) string

func GetModelByName

func GetModelByName(modelName string) configmodels.Model

func IsLastIndexInMap

func IsLastIndexInMap[K string, V any](m map[K]V, index int) bool

func IsLastIndexInSlice

func IsLastIndexInSlice[T any](arr []T, index int) bool

func RunCleanupShellCommands

func RunCleanupShellCommands(appName string, appPath string)

func TypeOf

func TypeOf(str string) string

func ZeroReturnValues

func ZeroReturnValues(returns string) string

func ZeroValue

func ZeroValue(valueType string) string

Types

type FileExtension

type FileExtension string
const (
	Go   FileExtension = ".go"
	Yaml FileExtension = ".yaml"
	None FileExtension = ""
)

type FileLocation

type FileLocation int64
const (
	Model FileLocation = iota
	Handler
	Root
	Cmd
	Wire
	Config
	API
	Service
	DockerCompose
	Dockerfile
	DB
	Repo
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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