utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateLogger

func CreateLogger(logFile string) (*slog.Logger, error)

CreateLogger create logger by log file If log file directory not exist, create it

func GetElemType

func GetElemType(valueOf reflect.Value) reflect.Type

func GetElemValue

func GetElemValue(valueOf reflect.Value) reflect.Value

func GetFieldNames

func GetFieldNames(typeOf reflect.Type) (names []string)

func GetTableID

func GetTableID(typeOf reflect.Type) (reflect.StructField, bool)

func GetTableModel

func GetTableModel(fieldOf reflect.Value) reflect.Value

func GetTagValue

func GetTagValue(tag string, key string) (string, bool)

func HasTagValue

func HasTagValue(tag string, key string) bool

func IsFieldHasSchema

func IsFieldHasSchema(valueOf reflect.Value, i int) bool

IsFieldHasSchema check if field has schema tag or schema suffix

func IsTableModel

func IsTableModel(fieldOf reflect.Value) bool

func MakeDirForFile

func MakeDirForFile(filename string) (err error)

MakeDirForFile create directory for file if not exist

func ParseSchemaTag

func ParseSchemaTag(tag string) (schema, prefix string)

ParseSchemaTag parses the schema tag and returns the schema name and table prefix. Example: "public;prefix:t_" returns ("public", "t_") Example: "auth" returns ("auth", "")

func ParseTableNameByType

func ParseTableNameByType(typeOf reflect.Type) string

ParseTableNameByType parse table name by type

func ParseTableNameByValue

func ParseTableNameByValue(valueOf reflect.Value) string

ParseTableNameByValue parse table name by value

func TableNameMethod

func TableNameMethod(valueOf reflect.Value) string

TableNameMethod try to get table name from method TableNames If method TableNames is not found, return empty string

func TableNamePattern

func TableNamePattern(name string) string

TableNamePattern is the default name patterning for mapping struct to table

func TitleCase

func TitleCase(word string) string

func ToSnakeCase

func ToSnakeCase(name string) string

ToSnakeCase convert camelCase or PascalCase to snake_case

Types

type CoMap

type CoMap[K int | int64 | string, V any] struct {
	// contains filtered or unexported fields
}

CoMap is a thread-safe concurrent map with read-write locking.

func NewCoMap

func NewCoMap[K int64 | string, V any]() *CoMap[K, V]

func (*CoMap[K, V]) Delete

func (m *CoMap[K, V]) Delete(key K)

func (*CoMap[K, V]) Each

func (m *CoMap[K, V]) Each() iter.Seq2[K, *V]

func (*CoMap[K, V]) Get

func (m *CoMap[K, V]) Get(key K) (*V, bool)

func (*CoMap[K, V]) Keys

func (m *CoMap[K, V]) Keys() []K

func (*CoMap[K, V]) Set

func (m *CoMap[K, V]) Set(key K, value *V)

func (*CoMap[K, V]) Size

func (m *CoMap[K, V]) Size() int

func (*CoMap[K, V]) Update

func (m *CoMap[K, V]) Update(data map[K]*V)

Jump to

Keyboard shortcuts

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