package selector import "context" type peerKey struct { } type Peer struct { Node } func NewPeerContext(ctx context.Context, node *Peer) context.Context { return context.WithValue(ctx, peerKey{}, node) } func FromPeerContext(ctx context.Context) (p *Peer, ok bool) { p, ok = ctx.Value(peerKey{}).(*Peer) return }