table_formatting

package
v0.0.0-...-f887b8c Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Taggers tagger.Tagger
	Caser   = cases.Title(language.English, cases.NoLower)
	// Initialisms some strings for idiomatic go in column names
	// see https://github.com/golang/go/wiki/CodeReviewComments#initialisms
	Initialisms = []string{"ID", "JSON", "XML", "HTTP", "URL"}
)

Functions

func CamelCaseString

func CamelCaseString(s string) string

func CreateTableStructString

func CreateTableStructString(settings *settings.Settings, db database.Database, table *database.Table) (string, string, error)

func FormatColumnName

func FormatColumnName(settings *settings.Settings, column, table string) (string, error)

FormatColumnName checks for invalid characters and transforms a column name according to the provided settings.

func FormatTableName

func FormatTableName(settings *settings.Settings, table *database.Table) string

func GenerateImports

func GenerateImports(content *strings.Builder, settings *settings.Settings, columnInfo ColumnInfo)

func GetNullType

func GetNullType(settings *settings.Settings, primitive string, sql string) string

func IndexCaseInsensitive

func IndexCaseInsensitive(s, substr string) int

func ReplaceSpace

func ReplaceSpace(r rune) rune

ReplaceSpace swaps any Unicode space characters for underscores to create valid Go identifiers

func ToInitialisms

func ToInitialisms(s string) string

func ValidVariableName

func ValidVariableName(s string) bool

ValidVariableName checks for the existence of any characters outside of Unicode letters, numbers and underscore.

Types

type ColumnInfo

type ColumnInfo struct {
	// contains filtered or unexported fields
}

func MapDbColumnTypeToGoType

func MapDbColumnTypeToGoType(s *settings.Settings, db database.Database, column database.Column) (goType string, columnInfo ColumnInfo)

type TableContentMap

type TableContentMap struct {
	TableContent map[string]string
	TableMap     map[string]*database.Table
}

func NewTableContentMap

func NewTableContentMap() TableContentMap

func (*TableContentMap) ProcessTables

func (t *TableContentMap) ProcessTables(db database.Database, settings *settings.Settings, tables ...*database.Table) error

Jump to

Keyboard shortcuts

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