1
0
forked from MTSR/mapserver
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" CONFIG_PSQL_PLAYER_CONNECTION string = "pgsql_player_connection"
) )
type PsqlConfig struct {
Host string
Port int
Username string
Password string
DbName string
}
type WorldConfig struct { type WorldConfig struct {
Backend string Backend string
PlayerBackend string PlayerBackend string
PsqlConnection map[string]string PsqlConnection *PsqlConfig
PsqlPlayerConnection map[string]string PsqlPlayerConnection *PsqlConfig
} }
func parseConnectionString(str string) map[string]string { func parseConnectionString(str string) *PsqlConfig {
return make(map[string]string) return &PsqlConfig{}
} }
func Parse(filename string) WorldConfig { func Parse(filename string) WorldConfig {
@ -39,7 +47,6 @@ func Parse(filename string) WorldConfig {
defer file.Close() defer file.Close()
cfg := WorldConfig{} cfg := WorldConfig{}
cfg.PsqlConnection = parseConnectionString("")
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {

View File

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