Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: fix config parsing. #225

Merged
merged 1 commit into from
Jul 28, 2016
Merged

config: fix config parsing. #225

merged 1 commit into from
Jul 28, 2016

Conversation

huachaohuang
Copy link
Contributor

Fix some bugs here.

PTAL @qiuyesuifeng @siddontang @shenli

@siddontang
Copy link
Contributor

LGTM
but what't the problem before?

@@ -145,22 +145,21 @@ func adjustInt64(v *int64, defValue int64) {

// Parse parses flag definitions from the argument list.
func (c *Config) Parse(arguments []string) error {
flagArgs := make(map[string]*flag.Flag)
flag.Visit(func(flag *flag.Flag) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Visit() function visits only those flags that have been set.
Before we Parse(), all flags are unset, so we always get an empty flagArgs.

@shenli
Copy link
Member

shenli commented Jul 28, 2016

LGTM

if err != nil {
return errors.Trace(err)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving line 168 check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only do a trick to get the config file here, we should leave the check at the end.
I don't think we should care performance here.

@huachaohuang huachaohuang merged commit a096dd2 into master Jul 28, 2016
@huachaohuang huachaohuang deleted the huachaohuang/fix-config branch July 28, 2016 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants