From 38c90d2417ca8feeeee6dc3dc2f947f421fbd80c Mon Sep 17 00:00:00 2001 From: William Chang Date: Fri, 19 Aug 2022 12:54:05 -0400 Subject: [PATCH] Restored condition to check for number of parameters above expected number (now 4). Also changed for loop to be more idiomatic. --- plugin.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.go b/plugin.go index 45b047a..e8470f4 100644 --- a/plugin.go +++ b/plugin.go @@ -163,17 +163,18 @@ func ParseOptions(req *plugin_go.CodeGeneratorRequest) (*PluginOptions, error) { } parts := strings.Split(params, ",") - if len(parts) < 2 { + if len(parts) < 2 || len(parts) > 4 { return nil, fmt.Errorf("Invalid parameter: %s", params) } options.TemplateFile = parts[0] options.OutputFile = path.Base(parts[1]) + // Handle extra options if len(parts) > 2 { extraOptions := parts[2:] - for i := 0; i < len(extraOptions); i++ { + for i := range extraOptions { switch i { case 0: // Third option switch extraOptions[i] { @@ -194,7 +195,6 @@ func ParseOptions(req *plugin_go.CodeGeneratorRequest) (*PluginOptions, error) { return nil, fmt.Errorf("Invalid parameter: %s", params) } } - } }