helper

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCaseSlice

func CamelCaseSlice(elem []string) string

CamelCaseSlice returns the camel case of a slice.

func CheckProtoSyntax

func CheckProtoSyntax(file *descriptorpb.FileDescriptorProto) error

CheckProtoSyntax checks if the syntax of the file is proto3.

func ClearPointer

func ClearPointer(s string) string

ClearPointer removes the pointer and slice from a string.

func ConvertType

func ConvertType(field *descriptorpb.FieldDescriptorProto) string

ConvertType converts a protobuf type to a Go type.

func ConvertTypeSQLite added in v1.1.0

func ConvertTypeSQLite(field *descriptorpb.FieldDescriptorProto) string

func CopyMessage added in v1.0.10

func DetectField

func DetectField(structName string) string

DetectField returns the field name.

func DetectMany

func DetectMany(t string) bool

DetectMany returns true if the field is a many relation.

func DetectReference

func DetectReference(structName string) string

DetectReference returns the reference field name.

func DetectStoreName

func DetectStoreName(t string) string

DetectStoreName returns the postgres type for the given type.

func DetectStructName

func DetectStructName(t string) string

DetectStructName returns the struct name for the given type.

func DetectTableName

func DetectTableName(t string) string

DetectTableName returns the postgres type for the given type.

func DetermineRelationDirection

func DetermineRelationDirection(rd *descriptorpb.DescriptorProto, pd *descriptorpb.DescriptorProto) string

DetermineRelationDirection determines the relation direction.

func DumpPrint

func DumpPrint(values ...interface{})

func ExecuteTemplate

func ExecuteTemplate(tmpl string, funcs template.FuncMap, data any, templates ...IncludeTemplate) (string, error)

ExecuteTemplate executes a template.

func FirstLetterLower

func FirstLetterLower(s string) (string, error)

FirstLetterLower converts the first letter of a string to lowercase.

func GetDBOptions

GetDBOptions returns the custom options for a file.

func GetFieldOptions

GetFieldOptions returns the custom options for a field.

func GetMessageOptions

GetMessageOptions returns the custom options for a message.

func GetUserProtoFile

GetUserProtoFile returns the first user proto file.

func GetUserProtoFiles

GetUserProtoFiles returns the user proto files.

func GoFmt

GoFmt formats the generated Go code.

func GoTypeToPostgresType

func GoTypeToPostgresType(goType string) string

GoTypeToPostgresType returns the postgres type for the given type.

func GoTypeToSQLiteType added in v1.1.0

func GoTypeToSQLiteType(goType string) string

GoTypeToSQLiteType returns the postgres type for the given type.

func HasIndex added in v1.0.3

HasIndex returns the index option for a field.

func HasUnique added in v1.0.3

HasUnique returns the unique option for a field.

func IsContainsStar

func IsContainsStar(s string) bool

IsContainsStar returns true if the string contains a star.

func IsOptional

func IsOptional(field *descriptorpb.FieldDescriptorProto) bool

IsOptional returns true if the field is optional and not a string, bytes, int32, int64, float32, float64, bool, uint32, uint64 type or a Google Protobuf wrapper message.

func IsRepeated

func IsRepeated(field *descriptorpb.FieldDescriptorProto) bool

IsRepeated returns true if the field is repeated.

func IsUserMessage

IsUserMessage returns true if the message is not a google.protobuf or structify message.

func LowerCamelCase

func LowerCamelCase(name string) string

LowerCamelCase converts a string to a lowerCamelCase string.

func LowerClientName

func LowerClientName(name string) string

LowerClientName returns the lowerCamelCase name of the client.

func Plural

func Plural(name string) string

Plural converts a string to a plural string.

func PostgresType

func PostgresType(goType string, options *structify.StructifyFieldOptions, isJson bool) string

PostgresType returns the postgres type for the given type.

func SQLiteType added in v1.1.0

func SQLiteType(goType string, options *structify.StructifyFieldOptions, isJson bool) string

func SliceToString

func SliceToString(slice []string) string

SliceToString converts a slice of strings to a string.

func SnakeCase added in v1.0.3

func SnakeCase(name string) string

func ToLower

func ToLower(name string) string

ToLower converts a string to a lower string.

func TypePrefix

func TypePrefix(field *descriptorpb.FieldDescriptorProto, typeName string) string

TypePrefix returns the type prefix.

func UpperCamelCase

func UpperCamelCase(name string) string

UpperCamelCase converts a string to a CamelCase string.

func UpperClientName

func UpperClientName(name string) string

UpperClientName returns the upperCamelCase name of the client.

Types

type DescriptorMList

type DescriptorMList map[string]*descriptorpb.DescriptorProto

DescriptorMList is a map of descriptors.

type IncludeTemplate

type IncludeTemplate struct {
	Name string
	Body string
}

Jump to

Keyboard shortcuts

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