all: Minor cleanups

if x { return true } return false => return x

	fmt.Sprintf("%v", x) => fmt.Sprint(x) or x.String()

The fmt.Sprintf idiom is still used in the SecretString tests, where it
serves security hardening.
This commit is contained in:
greatroar 2022-10-16 10:30:59 +02:00
parent d03460010f
commit 22147e1e02
5 changed files with 6 additions and 10 deletions

View File

@ -217,7 +217,7 @@ func TestTestWalkFiles(t *testing.T) {
return err return err
} }
got[p] = fmt.Sprintf("%v", item) got[p] = fmt.Sprint(item)
return nil return nil
}) })

View File

@ -97,7 +97,7 @@ func TestFiles(t *testing.T) {
} }
for _, tpe := range tests { for _, tpe := range tests {
t.Run(fmt.Sprintf("%v", tpe), func(t *testing.T) { t.Run(tpe.String(), func(t *testing.T) {
ids := generateRandomFiles(t, tpe, c) ids := generateRandomFiles(t, tpe, c)
id := randomID(ids) id := randomID(ids)

View File

@ -114,11 +114,7 @@ func (h BlobHandles) Less(i, j int) bool {
continue continue
} }
if b < h[j].ID[k] { return b < h[j].ID[k]
return true
}
return false
} }
return h[i].Type < h[j].Type return h[i].Type < h[j].Type
@ -133,5 +129,5 @@ func (h BlobHandles) String() string {
for _, e := range h { for _, e := range h {
elements = append(elements, e.String()) elements = append(elements, e.String())
} }
return fmt.Sprintf("%v", elements) return fmt.Sprint(elements)
} }

View File

@ -65,5 +65,5 @@ func (ids IDs) String() string {
for _, id := range ids { for _, id := range ids {
elements = append(elements, shortID(id)) elements = append(elements, shortID(id))
} }
return fmt.Sprintf("%v", elements) return fmt.Sprint(elements)
} }

View File

@ -37,7 +37,7 @@ func (TagList) Type() string {
type TagLists []TagList type TagLists []TagList
func (l TagLists) String() string { func (l TagLists) String() string {
return fmt.Sprintf("%v", []TagList(l)) return fmt.Sprint([]TagList(l))
} }
// Flatten returns the list of all tags provided in TagLists // Flatten returns the list of all tags provided in TagLists