package common import ( "gorm.io/driver/postgres" "gorm.io/gorm" ) func GetDataBaseClient() *gorm.DB { dsn := "host=localhost " + "user=gatekeeper " + "dbname=crimson " + "sslmode=disable " + "port=5432 " + "password=crimson " + "connect_timeout=20 " client, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}) if err != nil { panic("无法连接数据库") } return client }