This commit is contained in:
Thomas Rudin 2019-01-04 16:10:21 +01:00
parent 9fea93e73a
commit 8d399fb056
2 changed files with 13 additions and 6 deletions

View File

@ -19,16 +19,24 @@ const (
CONFIG_PSQL_PLAYER_CONNECTION string = "pgsql_player_connection"
)
type PsqlConfig struct {
Host string
Port int
Username string
Password string
DbName string
}
type WorldConfig struct {
Backend string
PlayerBackend string
PsqlConnection map[string]string
PsqlPlayerConnection map[string]string
PsqlConnection *PsqlConfig
PsqlPlayerConnection *PsqlConfig
}
func parseConnectionString(str string) map[string]string {
return make(map[string]string)
func parseConnectionString(str string) *PsqlConfig {
return &PsqlConfig{}
}
func Parse(filename string) WorldConfig {
@ -39,7 +47,6 @@ func Parse(filename string) WorldConfig {
defer file.Close()
cfg := WorldConfig{}
cfg.PsqlConnection = parseConnectionString("")
scanner := bufio.NewScanner(file)
for scanner.Scan() {

View File

@ -33,7 +33,7 @@ func TestParsePostgres(t *testing.T) {
t.Fatal("no connection")
}
if cfg.PsqlConnection[""] != "x" {
if cfg.PsqlConnection.Host != "postgres" {
t.Fatal("param err")
}
}