Skip to content

Enable perfsprint linter and fix up code issues#14091

Merged
beorn7 merged 1 commit intoprometheus:mainfrom
alexandear:enable-perfsprint-linter
May 15, 2024
Merged

Enable perfsprint linter and fix up code issues#14091
beorn7 merged 1 commit intoprometheus:mainfrom
alexandear:enable-perfsprint-linter

Conversation

@alexandear
Copy link
Copy Markdown
Contributor

This PR enables perfsprint linter and fixes its issues.

Changes that improve both readability and performance are:

  • replace fmt.Sprintf("%d", x), fmt.Sprint(x) with strconv.Itoa(x) for int values;
  • replace fmt.Sprintf("%t", b) with strconv.FormatBool(b) for bool values;
  • replace fmt.Sprintf("%d", x) with strconv.FormatInt for int64 values;
  • replace fmt.Sprintf("%d", x) with strconv.FormatUint for uint64 values;
  • remove redundant fmt.Sprint statements.

Copy link
Copy Markdown
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

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

Looks good, just wondering about the text entry in .golangci.yml.

@alexandear alexandear requested a review from beorn7 May 15, 2024 14:51
@beorn7 beorn7 merged commit 806073a into prometheus:main May 15, 2024
@alexandear alexandear deleted the enable-perfsprint-linter branch May 15, 2024 15:48
@machine424
Copy link
Copy Markdown
Member

Thanks @alexandear for this and @beorn7 for the review.

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.

3 participants