MCPcopy
hub / github.com/grpc/grpc-go / String

Method String

peer/peer.go:46–70  ·  view source on GitHub ↗

String ensures the Peer types implements the Stringer interface in order to allow to print a context with a peerKey value effectively.

()

Source from the content-addressed store, hash-verified

44// String ensures the Peer types implements the Stringer interface in order to
45// allow to print a context with a peerKey value effectively.
46func (p *Peer) String() string {
47 if p == nil {
48 return "Peer<nil>"
49 }
50 sb := &strings.Builder{}
51 sb.WriteString("Peer{")
52 if p.Addr != nil {
53 fmt.Fprintf(sb, "Addr: '%s', ", p.Addr.String())
54 } else {
55 fmt.Fprintf(sb, "Addr: <nil>, ")
56 }
57 if p.LocalAddr != nil {
58 fmt.Fprintf(sb, "LocalAddr: '%s', ", p.LocalAddr.String())
59 } else {
60 fmt.Fprintf(sb, "LocalAddr: <nil>, ")
61 }
62 if p.AuthInfo != nil {
63 fmt.Fprintf(sb, "AuthInfo: '%s'", p.AuthInfo.AuthType())
64 } else {
65 fmt.Fprintf(sb, "AuthInfo: <nil>")
66 }
67 sb.WriteString("}")
68
69 return sb.String()
70}
71
72type peerKey struct{}
73

Calls 2

StringMethod · 0.65
AuthTypeMethod · 0.65