README ¶ gorm'er —— GORM Manager Installation go get github.com/go-packagist/gormer Usage package main import ( "github.com/go-packagist/gormer" "gorm.io/driver/mysql" "gorm.io/gorm" ) type User struct { Username string Password string } func main() { g := gormer.New(&gormer.Config{ Default: "db1", Connections: map[string]gormer.ConnectionFunc{ "db1": func() *gorm.DB { return nil }, "db2": func() *gorm.DB { dsn := "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local" db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) if err != nil { panic(err) } return db }, }, }) g.Connection().First(&User{}) // use default connection(Recommended usage) g.Connection("db1").First(&User{}) // use db1 connection g.Connection("db2").First(&User{}) } License The MIT License (MIT). Please see License File for more information. Expand ▾ Collapse ▴ Documentation ¶ Index ¶ type Config type ConnectionFunc type Manager func New(config *Config) *Manager func NewManager(config *Config) *Manager func (m *Manager) Connection(name ...string) *gorm.DB Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type Config ¶ type Config struct { Default string Connections map[string]ConnectionFunc } type ConnectionFunc ¶ type ConnectionFunc func() *gorm.DB type Manager ¶ type Manager struct { // contains filtered or unexported fields } func New ¶ added in v1.1.0 func New(config *Config) *Manager func NewManager ¶ func NewManager(config *Config) *Manager func (*Manager) Connection ¶ func (m *Manager) Connection(name ...string) *gorm.DB Source Files ¶ View all Source files manager.go Click to show internal directories. Click to hide internal directories.