Skip to content

Commit

Permalink
format: fix renderer (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
lspgn authored Dec 6, 2023
1 parent ac5e849 commit e1c581e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions format/common/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ func FormatMessageReflectCustom(msg interface{}, ext, quotes, sep, sign string,
}
fieldValue := vfm.FieldByName(fieldName)
// todo: replace s by json mapping of protobuf
if fieldValue.IsValid() {
if renderer, ok := RenderExtras[fieldName]; ok {
fstr[i] = fmt.Sprintf("%s%s%s%s%q", quotes, s, quotes, sign, renderer(msg))
i++
} else if fieldValue.IsValid() {

if fieldType, ok := TextFields[fieldName]; ok {
switch fieldType {
Expand All @@ -213,8 +216,6 @@ func FormatMessageReflectCustom(msg interface{}, ext, quotes, sep, sign string,

}
}
} else if renderer, ok := RenderExtras[fieldName]; ok {
fstr[i] = fmt.Sprintf("%s%s%s%s%q", quotes, s, quotes, sign, renderer(msg))
} else {
// handle specific types here
switch fieldValue.Kind() {
Expand Down

0 comments on commit e1c581e

Please sign in to comment.