Documentation
¶
Index ¶
- Constants
- func Generate(c *Config) error
- func Init(cfg *Config) error
- type Config
- type DataType
- type DatabaseConfig
- type DatabaseOperatorConfig
- type EmptyMatcher
- type ExecConfig
- type Expr
- type ExprParams
- type FileMatcher
- type Generator
- type GetterConfig
- type Matcher
- type MigrationConfig
- type Package
- type RegexMatcher
- type SqlDriver
Constants ¶
View Source
const ( TagOptionAutoIncrement = "auto_increment" TagOptionBinary = "binary" TagOptionPKAlias = "pk" TagOptionPK = "primary_key" TagOptionFKAlias = "fk" TagOptionFK = "foreign_key" TagOptionUnsigned = "unsigned" TagOptionSize = "size" TagOptionDataType = "data_type" TagOptionEncode = "encode" TagOptionDecode = "decode" TagOptionUnique = "unique" TagOptionIndex = "index" )
View Source
const ( SnakeCase naming = "snake_case" CamelCase naming = "camelCase" PascalCase naming = "PascalCase" )
View Source
const ( DefaultConfigFile = "sqlgen.yml" DefaultGeneratedFile = "generated.go" DefaultStructTag = "sql" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Source []string `yaml:"src"` Driver SqlDriver `yaml:"driver"` // The possibly values of naming convention are // SnakeCase // PascalCase // CamelCase NamingConvention naming `yaml:"naming_convention,omitempty"` Tag string `yaml:"struct_tag,omitempty"` // Whether to quote the table name or column name QuoteIdentifier bool `yaml:"quote_identifier"` ReadOnly bool `yaml:"read_only"` Strict *bool `yaml:"strict,omitempty"` Exec ExecConfig `yaml:"exec"` Getter GetterConfig `yaml:"getter"` Migration *MigrationConfig `yaml:"migration"` Database *DatabaseConfig `yaml:"database"` OmitGetters bool `yaml:"omit_getters,omitempty"` SourceMap bool `yaml:"source_map"` SkipHeader bool `yaml:"skip_header"` SkipModTidy bool `yaml:"skip_mod_tidy"` DataTypes map[string]DataType `yaml:"data_types"` }
func DefaultConfig ¶
func DefaultConfig() *Config
func LoadConfigFrom ¶
func (Config) RenameFunc ¶
type DatabaseConfig ¶
type DatabaseConfig struct { Package string `yaml:"package"` Dir string `yaml:"dir"` Filename string `yaml:"filename"` Operator *DatabaseOperatorConfig `yaml:"operator"` }
type DatabaseOperatorConfig ¶
type EmptyMatcher ¶
type EmptyMatcher struct{}
func (*EmptyMatcher) Match ¶
func (*EmptyMatcher) Match(v string) bool
type ExecConfig ¶
type Expr ¶
type Expr string
Currently this template is support following expression:
- {{.}} - current go path
- {{goPath}} - go path
- {{addrOfGoPath}} - address of go path
- {{len}} - go array size
type ExprParams ¶
type FileMatcher ¶
type FileMatcher map[string]struct{}
func (FileMatcher) Match ¶
func (f FileMatcher) Match(v string) bool
type Generator ¶
func (*Generator) QuoteIdentifier ¶
type GetterConfig ¶
type GetterConfig struct {
Prefix string `yaml:"prefix"`
}
type MigrationConfig ¶
type RegexMatcher ¶
func (*RegexMatcher) Match ¶
func (r *RegexMatcher) Match(v string) bool
Source Files
¶
Click to show internal directories.
Click to hide internal directories.