+
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions github/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Stringify(message interface{}) string {

func stringifyValue(w *bytes.Buffer, val reflect.Value) {
if val.Kind() == reflect.Ptr && val.IsNil() {
w.Write([]byte("<nil>"))
w.WriteString("<nil>")
return
}

Expand All @@ -37,20 +37,20 @@ func stringifyValue(w *bytes.Buffer, val reflect.Value) {
case reflect.String:
fmt.Fprintf(w, `"%s"`, v)
case reflect.Slice:
w.Write([]byte{'['})
w.WriteByte('[')
for i := 0; i < v.Len(); i++ {
if i > 0 {
w.Write([]byte{' '})
w.WriteByte(' ')
}

stringifyValue(w, v.Index(i))
}

w.Write([]byte{']'})
w.WriteByte(']')
return
case reflect.Struct:
if v.Type().Name() != "" {
w.Write([]byte(v.Type().String()))
w.WriteString(v.Type().String())
}

// special handling of Timestamp values
Expand All @@ -59,7 +59,7 @@ func stringifyValue(w *bytes.Buffer, val reflect.Value) {
return
}

w.Write([]byte{'{'})
w.WriteByte('{')

var sep bool
for i := 0; i < v.NumField(); i++ {
Expand All @@ -75,17 +75,17 @@ func stringifyValue(w *bytes.Buffer, val reflect.Value) {
}

if sep {
w.Write([]byte(", "))
w.WriteString(", ")
} else {
sep = true
}

w.Write([]byte(v.Type().Field(i).Name))
w.Write([]byte{':'})
w.WriteString(v.Type().Field(i).Name)
w.WriteByte(':')
stringifyValue(w, fv)
}

w.Write([]byte{'}'})
w.WriteByte('}')
default:
if v.CanInterface() {
fmt.Fprint(w, v.Interface())
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载