From e0dc9672ac8fd3ea45c42ea2f16a7798d696a4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=84=E6=BD=AD?= Date: Mon, 17 Mar 2025 15:02:22 +0800 Subject: [PATCH] support nil option in NewCommonVmCtx (#1909) --- plugins/wasm-go/pkg/wrapper/plugin_wrapper.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go b/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go index a83693255..6e31f0d2d 100644 --- a/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go +++ b/plugins/wasm-go/pkg/wrapper/plugin_wrapper.go @@ -258,7 +258,13 @@ func parseEmptyPluginConfig[PluginConfig any](gjson.Result, *PluginConfig, Log) func NewCommonVmCtx[PluginConfig any](pluginName string, options ...CtxOption[PluginConfig]) *CommonVmCtx[PluginConfig] { logger := &DefaultLog{pluginName, "nil"} - opts := append([]CtxOption[PluginConfig]{WithLogger[PluginConfig](logger)}, options...) + opts := []CtxOption[PluginConfig]{WithLogger[PluginConfig](logger)} + for _, opt := range options { + if opt == nil { + continue + } + opts = append(opts, opt) + } return NewCommonVmCtxWithOptions(pluginName, opts...) }