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

flag: arg conditional expression can be simplified #21763

Closed
alexpantyukhin opened this issue Sep 5, 2017 · 5 comments
Closed

flag: arg conditional expression can be simplified #21763

alexpantyukhin opened this issue Sep 5, 2017 · 5 comments

Comments

@alexpantyukhin
Copy link
Contributor

I have found redundant check in the parseOne() function.

  1. https://github.com/golang/go/blob/master/src/flag/flag.go#L842
	if len(s) == 0 || s[0] != '-' || len(s) == 1 {
		return false, nil
	}

is equivalent

	if len(s) < 2 || s[0] != '-' {
		return false, nil
	}
@gopherbot gopherbot added this to the Proposal milestone Sep 5, 2017
@cznic
Copy link
Contributor

cznic commented Sep 5, 2017

s/remove redundant check/simplify expression/

@mvdan
Copy link
Member

mvdan commented Sep 5, 2017

@alexpantyukhin feel free to submit a patch - see https://golang.org/doc/contribute.html.

@alexpantyukhin
Copy link
Contributor Author

@mvdan Thanks! already did. Also reviewing the method I found that flags names allowed to contain almost all characters (for example ".myint", "?/_", "). Is it ok? Are there some constraints for console parameters names?

@mvdan mvdan changed the title proposal: remove from flag/flag.go redundant checks. flag: arg conditional expression can be simplified Sep 5, 2017
@mvdan mvdan removed the Proposal label Sep 5, 2017
@mvdan mvdan removed this from the Proposal milestone Sep 5, 2017
@mvdan
Copy link
Member

mvdan commented Sep 5, 2017

Using a proposal for this is overkill, so I've removed it from the proposal list.

I've reviewed your CL. In the future, for such small changes, just post the CL. Even if you're wrong, it can be discussed on Gerrit.

Of course, this wouldn't apply to small changes that would be controversial or that would require lots of design and discussion.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/61491 mentions this issue: flag: simplify arg logic in parseOne

@golang golang locked and limited conversation to collaborators Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants