Skip to content
Open
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
13 changes: 11 additions & 2 deletions pkg/grpc/snapshot.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package grpc

import "strings"
import (
"fmt"
"reflect"
"strings"
)

type ProtoMessage interface {
String() string
Expand All @@ -9,8 +13,13 @@ type ProtoMessage interface {
// StringifySnapshot converts a protobuf response to a string and removes all double spaces.
// This is needed because of a pseudo-random effect https://github.com/golang/protobuf/issues/1121
func StringifySnapshot(resp ProtoMessage) string {
if resp == nil {
return "(interface {}) <nil>"
}

respType := reflect.TypeOf(resp).String()
respStr := resp.String()
respStr = strings.ReplaceAll(respStr, " ", " ")

return respStr
return fmt.Sprintf("(%s)(%s)", respType, respStr)
}