Add --version flag and display version on startup
This commit is contained in:
21
gormcol.go
21
gormcol.go
@@ -1,17 +1,3 @@
|
||||
// Package gormcol provides type-safe GORM column descriptors.
|
||||
//
|
||||
// This package enables defining struct-like variables that map Go field names
|
||||
// to database column names, allowing type-safe queries in GORM.
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// var PsAccessCols = struct {
|
||||
// IDProfile gormcol.Field
|
||||
// IDAuthorizationRole gormcol.Field
|
||||
// }{
|
||||
// IDProfile: gormcol.Field{}.Set((&PsAccess{}).TableName(), "id_profile"),
|
||||
// IDAuthorizationRole: gormcol.Field{}.Set((&PsAccess{}).TableName(), "id_authorization_role"),
|
||||
// }
|
||||
package gormcol
|
||||
|
||||
// Field represents a GORM column descriptor.
|
||||
@@ -21,18 +7,25 @@ type Field struct {
|
||||
column string // Database column name
|
||||
}
|
||||
|
||||
// TabCol returns the fully qualified "table.column" reference.
|
||||
func (f Field) TabCol() string {
|
||||
return f.table + "." + f.column
|
||||
}
|
||||
|
||||
// Col returns the column name without table qualification.
|
||||
func (f Field) Col() string {
|
||||
return f.column
|
||||
}
|
||||
|
||||
// Tab returns the table name.
|
||||
func (f Field) Tab() string {
|
||||
return f.table
|
||||
}
|
||||
|
||||
// Set initializes a Field with the given table and column names.
|
||||
// Use with TableName() for type-safe initialization, e.g.:
|
||||
//
|
||||
// Field{}.Set((&MyModel{}).TableName(), "column_name")
|
||||
func (f Field) Set(tab, field string) Field {
|
||||
return Field{
|
||||
table: tab,
|
||||
|
||||
Reference in New Issue
Block a user