Summary
The database DSN in hot_storage/sample/db.go is constructed via fmt.Sprintf:
dsn := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=%s", user, password, host, port, name, sslmode)
If DB_PASS contains URL-reserved characters (@, :, /, ?, #), the connection string breaks or is misinterpreted.
Affected Files
Recommendation
Use net/url package for proper URL encoding:
u := &url.URL{
Scheme: "postgres",
User: url.UserPassword(user, password),
Host: fmt.Sprintf("%s:%s", host, port),
Path: name,
RawQuery: fmt.Sprintf("sslmode=%s", sslmode),
}
dsn := u.String()
Summary
The database DSN in
hot_storage/sample/db.gois constructed viafmt.Sprintf:If
DB_PASScontains URL-reserved characters (@,:,/,?,#), the connection string breaks or is misinterpreted.Affected Files
hot_storage/sample/db.goRecommendation
Use
net/urlpackage for proper URL encoding: