enums

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEnums

func GenerateEnums(pkgNames []string, suffix ...string) (sql string, err error)

For all enumerated constants, generate enums that satisfy the Enummer interface suffix is appended to each filename e.g Uses _enum by default. Returns sql string that you can use to create these ENUM types in postgres

func ImplementsEnumer

func ImplementsEnumer(field reflect.StructField) bool

func QuoteEnums

func QuoteEnums(values []string) string

Surround each value with single quote and return a comma-seperated string

Types

type Enumer

type Enumer interface {
	sql.Scanner
	driver.Valuer
	ValidValues() []string
	DatabaseType() string
}

Enumer interface embeds sql.Scanner interface, database/driver.Valuer. Has 2 methods ValidValues()[]string to return valid enums and DatabaseType() that returns the sql data type.

Jump to

Keyboard shortcuts

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