github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/common/environment/envctx/env.go (about) 1 package envctx 2 3 import "context" 4 5 const ( 6 environmentKey string = "v2.environment" 7 ) 8 9 func ContextWithEnvironment(ctx context.Context, environment interface{}) context.Context { 10 return context.WithValue(ctx, environmentKey, environment) //nolint: revive,staticcheck 11 } 12 13 func EnvironmentFromContext(ctx context.Context) interface{} { 14 return ctx.Value(environmentKey) 15 }