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

gci: Parse the settings more similarly to the cli #2217

Merged
merged 2 commits into from
Sep 4, 2021

Conversation

LukeShu
Copy link
Contributor

@LukeShu LukeShu commented Sep 3, 2021

The gci command line parses the -local flag using the gci.ParseLocalFlag helper function,
which is different than strings.Split (which golangci-lint uses) in that it handles the empty string (which golangci-lint separately handles)
and that it handles empty entries in the list (which golangci-lint does not handle).

For example, the gci command line parses "-local foo,,bar" as the list ["foo", "bar"], but golangci-lint parses the YAML "local-prefixes: foo,,bar" as the list ["foo", "", "bar"].

This is a silly discrepancy to have; just use the gci.ParseLocalFlag helper function!

The gci command line parses the -local flag using the gci.ParseLocalFlag
helper function, which is different than strings.Split (which
golangci-lint uses) in that it handles the empty string (which
golangci-lint separately handles) and that it handles empty entries in the
list (which golangci-lint does not handle).

For example, the gci command line parses "-local foo,,bar" as the list
["foo", "bar"], but golangci-lint parses the YAML
"local-prefixes: foo,,bar" as the list ["foo", "", "bar"].

This is a silly discrepancy to have; just use the gci.ParseLocalFlag
helper function!
@ldez ldez added the enhancement New feature or improvement label Sep 3, 2021
@ldez ldez merged commit 54f4301 into golangci:master Sep 4, 2021
SeigeC pushed a commit to SeigeC/golangci-lint that referenced this pull request Apr 4, 2023
@ldez ldez added this to the v1.42 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants