Open YoungWing opened 5 years ago
test code like this:
o := make(map[string]string) dsn := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", "localhost", 5432, "test", "", "testDB", ) parseOpts(dsn, o) fmt.Println(o)
output:
map[host:localhost password:dbname=testDB port:5432 sslmode:disable user:test]
in this map, we can see the passwd value is that "dbname=testDB" rather than ""
In this case,it is a wrong dsn parser?
Or when my passwd is null, I can only put passwd end of dsn,like this:
dsn := fmt.Sprintf("host=%s port=%d user=%s dbname=%s sslmode=disable password=%s", "localhost", 5432, "test", "testDB", "", )
Blank values need to be wrapped in single quotes. The package docs could be more explicit about this.
To write an empty value, or a value containing spaces, surround it with single quotes
test code like this:
output:
in this map, we can see the passwd value is that "dbname=testDB" rather than ""
In this case,it is a wrong dsn parser?
Or when my passwd is null, I can only put passwd end of dsn,like this: