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: Value example use code that is reported by golint #45622

Closed
perillo opened this issue Apr 18, 2021 · 3 comments
Closed

flag: Value example use code that is reported by golint #45622

perillo opened this issue Apr 18, 2021 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.

Comments

@perillo
Copy link
Contributor

perillo commented Apr 18, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.3 linux/amd64

Does this issue reproduce with the latest release?

Yes.

The Value example in the flag package (https://golang.org/pkg/flag/#example_Value) uses the code:

if u, err := url.Parse(s); err != nil {
	return err
} else {
	*v.URL = *u
}
return nil

golint reports:
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary).

Not sure if the code should be modified.

Thanks.

@ianlancetaylor
Copy link
Contributor

Sure, we can change the example code. Thanks.

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 19, 2021
@gopherbot
Copy link

Change https://golang.org/cl/311269 mentions this issue: flag: improve coding style in Value example

@mvdan
Copy link
Member

mvdan commented May 8, 2021

The change was abandoned; closing.

@mvdan mvdan closed this as completed May 8, 2021
@golang golang locked and limited conversation to collaborators May 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants