dataRT/config/postgres.go

121 lines
2.1 KiB
Go

package config
type postgresConfig struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
User string `json:"user" yaml:"user"`
Password string `json:"password" yaml:"password"`
DBName string `json:"dbname" yaml:"dbname"`
TimeZone string `json:"timezone" yaml:"timezone"`
}
func NewPostgresConfig() *postgresConfig {
return new(postgresConfig)
}
func (conf *postgresConfig) GetHost() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.Host
}
func (conf *postgresConfig) SetHost(host string) *postgresConfig {
if conf == nil {
panic("postgres config is nil")
}
conf.Host = host
return conf
}
func (conf *postgresConfig) GetPort() int {
if conf == nil {
panic("postgres config is nil")
}
return conf.Port
}
func (conf *postgresConfig) SetPort(port int) *postgresConfig {
if conf == nil {
panic("postgres config is nil")
}
conf.Port = port
return conf
}
func (conf *postgresConfig) GetUser() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.User
}
func (conf *postgresConfig) SetUser(user string) *postgresConfig {
if conf == nil {
panic("postgres config is nil")
}
conf.User = user
return conf
}
func (conf *postgresConfig) GetPassword() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.Password
}
func (conf *postgresConfig) SetPassword(password string) *postgresConfig {
if conf == nil {
panic("postgres config is nil")
}
conf.Password = password
return conf
}
func (conf *postgresConfig) GetDBName() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.DBName
}
func (conf *postgresConfig) SetDBName(dbName string) *postgresConfig {
if conf == nil {
panic("postgres config is nil")
}
conf.DBName = dbName
return conf
}
func (conf *postgresConfig) GetTimeZone() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.TimeZone
}
func (conf *postgresConfig) SetTimeZone(timeZone string) *postgresConfig {
if conf == nil {
panic("postgres config is nil")
}
conf.TimeZone = timeZone
return conf
}
func postgresConfigName() string {
return "postgres.json"
}