diff --git a/pkg/grpc/snapshot.go b/pkg/grpc/snapshot.go index 90faebe..3a806fc 100644 --- a/pkg/grpc/snapshot.go +++ b/pkg/grpc/snapshot.go @@ -1,6 +1,10 @@ package grpc -import "strings" +import ( + "fmt" + "reflect" + "strings" +) type ProtoMessage interface { String() string @@ -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 {}) " + } + + respType := reflect.TypeOf(resp).String() respStr := resp.String() respStr = strings.ReplaceAll(respStr, " ", " ") - return respStr + return fmt.Sprintf("(%s)(%s)", respType, respStr) }