testify icon indicating copy to clipboard operation
testify copied to clipboard

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

Open alexandear opened this issue 1 year ago • 0 comments

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 avatar Oct 30 '24 20:10 alexandear