github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/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 }