names

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package names provides naming convention mappers for converting between Go struct field names and database column/table names. Compatible with xorm's naming interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GonicMapper

type GonicMapper struct {
	Acronyms map[string]bool
}

GonicMapper is like SnakeMapper but treats common initialisms as single words (e.g. "ID" → "id", "HTTP" → "http", "URL" → "url").

func NewGonicMapper

func NewGonicMapper() GonicMapper

NewGonicMapper returns a GonicMapper with common Go initialisms.

func (GonicMapper) Obj2Table

func (m GonicMapper) Obj2Table(name string) string

func (GonicMapper) Table2Obj

func (m GonicMapper) Table2Obj(name string) string

type Mapper

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

Mapper defines the interface for name conversion between Go and SQL.

type PrefixMapper

type PrefixMapper struct {
	Mapper Mapper
	Prefix string
}

PrefixMapper adds a prefix to table names.

func (PrefixMapper) Obj2Table

func (m PrefixMapper) Obj2Table(name string) string

func (PrefixMapper) Table2Obj

func (m PrefixMapper) Table2Obj(name string) string

type SameMapper

type SameMapper struct{}

SameMapper performs no conversion — names pass through unchanged.

func (SameMapper) Obj2Table

func (SameMapper) Obj2Table(name string) string

func (SameMapper) Table2Obj

func (SameMapper) Table2Obj(name string) string

type SnakeMapper

type SnakeMapper struct{}

SnakeMapper converts CamelCase to snake_case and back.

func (SnakeMapper) Obj2Table

func (SnakeMapper) Obj2Table(name string) string

func (SnakeMapper) Table2Obj

func (SnakeMapper) Table2Obj(name string) string

Jump to

Keyboard shortcuts

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