names

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LintGonicMapper = GonicMapper{
	"API":   true,
	"ASCII": true,
	"CPU":   true,
	"CSS":   true,
	"DNS":   true,
	"EOF":   true,
	"GUID":  true,
	"HTML":  true,
	"HTTP":  true,
	"HTTPS": true,
	"ID":    true,
	"IP":    true,
	"JSON":  true,
	"LHS":   true,
	"QPS":   true,
	"RAM":   true,
	"RHS":   true,
	"RPC":   true,
	"SLA":   true,
	"SMTP":  true,
	"SSH":   true,
	"TLS":   true,
	"TTL":   true,
	"UI":    true,
	"UID":   true,
	"UUID":  true,
	"URI":   true,
	"URL":   true,
	"UTF8":  true,
	"VM":    true,
	"XML":   true,
	"XSRF":  true,
	"XSS":   true,
}

LintGonicMapper is A GonicMapper that contains a list of common initialisms taken from golang/lint

Functions

func GetTableComment

func GetTableComment(v reflect.Value) string

GetTableComment returns table comment

func GetTableName

func GetTableName(mapper Mapper, v reflect.Value) string

GetTableName returns table name

Types

type CacheMapper

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

CacheMapper represents a cache mapper

func NewCacheMapper

func NewCacheMapper(mapper Mapper) *CacheMapper

NewCacheMapper creates a cache mapper

func (*CacheMapper) Obj2Table

func (m *CacheMapper) Obj2Table(o string) string

Obj2Table implements Mapper

func (*CacheMapper) Table2Obj

func (m *CacheMapper) Table2Obj(t string) string

Table2Obj implements Mapper

type GonicMapper

type GonicMapper map[string]bool

GonicMapper implements IMapper. It will consider initialisms when mapping names. E.g. id -> ID, user -> User and to table names: UserID -> user_id, MyUID -> my_uid

func (GonicMapper) Obj2Table

func (mapper GonicMapper) Obj2Table(name string) string

Obj2Table implements Mapper

func (GonicMapper) Table2Obj

func (mapper GonicMapper) Table2Obj(name string) string

Table2Obj implements Mapper

type Mapper

type Mapper interface {
	Obj2Table(string) string
	Table2Obj(string) string
}

Mapper represents a name convertation between struct's fields name and table's column name

type PrefixMapper

type PrefixMapper struct {
	Mapper Mapper
	Prefix string
}

PrefixMapper provides prefix table name support

func NewPrefixMapper

func NewPrefixMapper(mapper Mapper, prefix string) PrefixMapper

NewPrefixMapper creates a prefix mapper

func (PrefixMapper) Obj2Table

func (mapper PrefixMapper) Obj2Table(name string) string

Obj2Table implements Mapper

func (PrefixMapper) Table2Obj

func (mapper PrefixMapper) Table2Obj(name string) string

Table2Obj implements Mapper

type SameMapper

type SameMapper struct {
}

SameMapper implements Mapper and provides same name between struct and database table

func (SameMapper) Obj2Table

func (m SameMapper) Obj2Table(o string) string

Obj2Table implements Mapper

func (SameMapper) Table2Obj

func (m SameMapper) Table2Obj(t string) string

Table2Obj implements Mapper

type SnakeMapper

type SnakeMapper struct {
}

SnakeMapper implements IMapper and provides name translation between struct and database table

func (SnakeMapper) Obj2Table

func (mapper SnakeMapper) Obj2Table(name string) string

Obj2Table implements Mapper

func (SnakeMapper) Table2Obj

func (mapper SnakeMapper) Table2Obj(name string) string

Table2Obj implements Mapper

type SuffixMapper

type SuffixMapper struct {
	Mapper Mapper
	Suffix string
}

SuffixMapper provides suffix table name support

func NewSuffixMapper

func NewSuffixMapper(mapper Mapper, suffix string) SuffixMapper

NewSuffixMapper creates a suffix mapper

func (SuffixMapper) Obj2Table

func (mapper SuffixMapper) Obj2Table(name string) string

Obj2Table implements Mapper

func (SuffixMapper) Table2Obj

func (mapper SuffixMapper) Table2Obj(name string) string

Table2Obj implements Mapper

type TableComment

type TableComment interface {
	TableComment() string
}

type TableName

type TableName interface {
	TableName() string
}

TableName table name interface to define customerize table name

Jump to

Keyboard shortcuts

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