Skip to content

Commit

Permalink
Replace fmt.Fprintf with b.WriteString
Browse files Browse the repository at this point in the history
  • Loading branch information
1911860538 committed Apr 4, 2024
1 parent 317d118 commit 345707e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions binding/default_validator.go
Expand Up @@ -5,8 +5,8 @@
package binding

import (
"fmt"
"reflect"
"strconv"
"strings"
"sync"

Expand All @@ -22,13 +22,17 @@ type SliceValidationError []error

// Error concatenates all error elements in SliceValidationError into a single string separated by \n.
func (err SliceValidationError) Error() string {
if len(err) == 0 {
return ""
}

var b strings.Builder
for i := range err {
for i := 0; i < len(err); i++ {
if err[i] != nil {
if b.Len() > 0 {
b.WriteString("\n")
}
fmt.Fprintf(&b, "[%d]: %s", i, err[i].Error())
b.WriteString("[" + strconv.Itoa(i) + "]: " + err[i].Error())
}
}
return b.String()
Expand Down

0 comments on commit 345707e

Please sign in to comment.