github.com/sagernet/sing-box@v1.9.0-rc.20/outbound/lookback.go (about) 1 package outbound 2 3 import "context" 4 5 type outboundTagKey struct{} 6 7 func ContextWithTag(ctx context.Context, outboundTag string) context.Context { 8 return context.WithValue(ctx, outboundTagKey{}, outboundTag) 9 } 10 11 func TagFromContext(ctx context.Context) (string, bool) { 12 value, loaded := ctx.Value(outboundTagKey{}).(string) 13 return value, loaded 14 }