Conversation
This adds a Config struct and NewConfig() to create it from a DSN and
environment. With this, you can do something like:
cfg, err := pq.NewConfig(os.Args[1])
if err != nil {
return err
}
if cfg.Host == "localhost" {
cfg.Host = "127.0.0.1"
}
c, err := pq.NewConnectorConfig(cfg)
if err != nil {
t.Fatal(err)
}
db := sql.OpenDB(c)
defer db.Close()
It also gives a nice place to document the options we support.
The actual code still uses a map, because rewriting all of that is a lot
of work. "TODO".
Fixes #856
Fixes #879
Fixes #909
Fixes #1202
b5ca876 to
0ab5dec
Compare
arp242
added a commit
that referenced
this pull request
Jan 21, 2026
The Config struct I added in #1240 wasn't directly used much but converted to a map, so I didn't need to rewrite all the code. This works well enough, but when working on multihost support (host=one,two) I found it's much more convenient to have access to the struct since it can parse (and validate) things to a slice on startup, instead of every time it's used. So just rewrite the lot.
arp242
added a commit
that referenced
this pull request
Jan 21, 2026
The Config struct I added in #1240 wasn't directly used much but converted to a map, so I didn't need to rewrite all the code. This works well enough, but when working on multihost support (host=one,two) I found it's much more convenient to have access to the struct since it can parse (and validate) things to a slice on startup, instead of every time it's used. So just rewrite the lot.
arp242
added a commit
that referenced
this pull request
Jan 21, 2026
The Config struct I added in #1240 wasn't directly used much but converted to a map, so I didn't need to rewrite all the code. This works well enough, but when working on multihost support (host=one,two) I found it's much more convenient to have access to the struct since it can parse (and validate) things to a slice on startup, instead of every time it's used. So just rewrite the lot.
|
this is great, thanks for doing it. Do you think you can cut a new release for this features? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a Config struct and NewConfig() to create it from a DSN and environment. With this, you can do something like:
It also gives a nice place to document the options we support.
The actual code still uses a map, because rewriting all of that is a lot of work. "TODO".
Fixes #856
Fixes #879
Fixes #909
Fixes #1202