Accept nil ctx in NewRuntime (#752)

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
This commit is contained in:
Anuraag Agrawal
2022-08-19 12:35:15 +09:00
committed by GitHub
parent 7f8e629c65
commit b93fd89637
2 changed files with 31 additions and 9 deletions

View File

@@ -127,6 +127,9 @@ func NewRuntime(ctx context.Context) Runtime {
// NewRuntimeWithConfig returns a runtime with the given configuration.
func NewRuntimeWithConfig(ctx context.Context, rConfig RuntimeConfig) Runtime {
if ctx == nil {
ctx = context.Background()
}
if v := ctx.Value(version.WazeroVersionKey{}); v == nil {
ctx = context.WithValue(ctx, version.WazeroVersionKey{}, wazeroVersion)
}