dataRT/config/postgres.go

118 lines
2.3 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"`
SSLMode string `json:"sslmode" yaml:"sslmode"`
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) {
if conf == nil {
panic("postgres config is nil")
}
conf.Host = host
}
func (conf *postgresConfig) GetPort() int {
if conf == nil {
panic("postgres config is nil")
}
return conf.Port
}
func (conf *postgresConfig) SetPort(port int) {
if conf == nil {
panic("postgres config is nil")
}
conf.Port = port
}
func (conf *postgresConfig) GetUser() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.User
}
func (conf *postgresConfig) SetUser(user string) {
if conf == nil {
panic("postgres config is nil")
}
conf.User = user
}
func (conf *postgresConfig) GetPassword() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.Password
}
func (conf *postgresConfig) SetPassword(password string) {
if conf == nil {
panic("postgres config is nil")
}
conf.Password = password
}
func (conf *postgresConfig) GetDBName() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.DBName
}
func (conf *postgresConfig) SetDBName(dbName string) {
if conf == nil {
panic("postgres config is nil")
}
conf.DBName = dbName
}
func (conf *postgresConfig) GetSSLMode() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.SSLMode
}
func (conf *postgresConfig) SetSSLMode(sslMode string) {
if conf == nil {
panic("postgres config is nil")
}
conf.SSLMode = sslMode
}
func (conf *postgresConfig) GetTimeZone() string {
if conf == nil {
panic("postgres config is nil")
}
return conf.TimeZone
}
func (conf *postgresConfig) SetTimeZone(timeZone string) {
if conf == nil {
panic("postgres config is nil")
}
conf.TimeZone = timeZone
}
func postgresConfigName() string {
return "postgres.json"
}