forked from MTSR/mapserver
use type
This commit is contained in:
parent
9fea93e73a
commit
8d399fb056
@ -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() {
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user