Make code more idiomatic#55
Open
stephenwithav wants to merge 8 commits into
Open
Conversation
cmd.Run returns an error value, which is nil when no error occurs, so nil-checking the ossible error in execute wastes cycles.
We may need findConfigOrFail to check more than strings in the future. This works until we reach that point.
Eliminates clutter.
Also, refactor the func.
abrightwell
requested changes
Aug 13, 2018
abrightwell
left a comment
Member
There was a problem hiding this comment.
Overall, these are all good changes. Some minor comments that I'd prefer to be addressed before approval.
| os.Exit(1) | ||
| } | ||
| findConfigOrFail(Primary, "Must specify a primary PostgreSQL instance.", 17) | ||
| findConfigOrFail(Replica, "Must specify a replica PostgreSQL instance for failover.", 18) |
Member
There was a problem hiding this comment.
Refactoring to a function seems good. But, I'd prefer that we not use arbitrary exit codes for this kind of failure. I believe that the original implementation of os.Exit(1) was sufficient for this purpose.
| rows, err := conn.Query("SELECT current_setting('server_version_num')") | ||
|
|
||
| if err != nil { | ||
| version := 0 |
Member
There was a problem hiding this comment.
For the purpose of being explicit about types related to queries, I'd prefer that it stay as var version int.
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 and #54 both branch from master.
They can be merged in either order, but some rebasing may need to occur between merges.
This branch refactors redundant code and makes better use of the of the
databas/sqlpackage.