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

refactor: use %q and %T to simplify fmt.Sprintf #1674

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alexandear
Copy link
Contributor

@alexandear alexandear commented Oct 30, 2024

Summary

The PR simplifies strings inside fmt.Sprintf statements.

Changes

Replace "\"%s\"" with %q.
Replace fmt.Sprintf("\"%s"\", reflect.TypeOf(t)) with fmt.Sprintf("%T", t).

Motivation

%q has fewer symbols than "\"%s\"" but means the same for strings. See https://pkg.go.dev/fmt#hdr-Printing:

%q	a double-quoted string safely escaped with Go syntax

%T is also shorter than reflect.TypeOf.

@alexandear alexandear force-pushed the refactor/simplify-with-sprintf-q branch from 9783d40 to d57bac8 Compare November 24, 2024 16:28
assert/assertion_compare.go Outdated Show resolved Hide resolved
assert/assertion_order.go Outdated Show resolved Hide resolved
mock/mock.go Outdated Show resolved Hide resolved
mock/mock.go Outdated Show resolved Hide resolved
@alexandear alexandear changed the title refactor: use %q to simplify fmt.Sprintf refactor: use %q and %T to simplify fmt.Sprintf Dec 10, 2024
@alexandear alexandear force-pushed the refactor/simplify-with-sprintf-q branch 2 times, most recently from da3dc7c to 8e9d214 Compare December 10, 2024 12:06
@alexandear alexandear force-pushed the refactor/simplify-with-sprintf-q branch from 8e9d214 to 30f3cef Compare December 10, 2024 12:08
@alexandear alexandear requested a review from dolmen December 10, 2024 12:11
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.

4 participants