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

Replace strings.SplitN(2) with strings.Cut #4022

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Conversation

joanlopez
Copy link
Contributor

What?

It updates the calls to strings.SplitN, with n=2 with strings.Cut, because most of the times that's why strings.Cut was added into the Go stdlib, as it makes the code involved more readable.

Why?

I started with a single // TODO I found while working on another task, but then realized that the codebase is plenty of calls to strings.SplitN with n=2, where most all the cases what we really want is to "cut" (split) a string containing key-values (e.g. key:value, key=value, etc).

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

@joanlopez joanlopez self-assigned this Oct 28, 2024
@joanlopez joanlopez requested a review from a team as a code owner October 28, 2024 09:39
@joanlopez joanlopez requested review from mstoykov and olegbespalov and removed request for a team October 28, 2024 09:39
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

nice, great job!

@joanlopez joanlopez merged commit a6e504a into master Oct 28, 2024
23 checks passed
@joanlopez joanlopez deleted the use-strings-cut branch October 28, 2024 12:23
@mstoykov mstoykov added this to the v0.55.0 milestone Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants