提交 0aff6873 作者: Brian Tiger Chow 提交者: Juan Batiz-Benet

fix(peer) perform bounds check on peer Id when printing String

上级 0c530bf5
......@@ -116,7 +116,12 @@ type peer struct {
// String prints out the peer.
func (p *peer) String() string {
return "[Peer " + p.id.String()[:12] + "]"
pid := p.id.String()
maxRunes := 12
if len(pid) < maxRunes {
maxRunes = len(pid)
}
return "[Peer " + pid[:maxRunes] + "]"
}
// Key returns the ID as a Key (string) for maps.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论