From cdbcef72a1b9f93d08455b5a77f7f7afa2b9f53d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 11 Sep 2020 14:55:50 +0100 Subject: fix nil pointer panic --- internal/clients/maprclient.go | 2 +- internal/regex/regex.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/clients/maprclient.go b/internal/clients/maprclient.go index 581db44..149129d 100644 --- a/internal/clients/maprclient.go +++ b/internal/clients/maprclient.go @@ -123,7 +123,7 @@ func (c MaprClient) makeCommands() (commands []string) { commands = append(commands, fmt.Sprintf("timeout %d %s %s %s", c.Timeout, modeStr, file, c.Regex.Serialize())) continue } - commands = append(commands, fmt.Sprintf("%s %s regex %s", modeStr, file, c.Regex.Serialize())) + commands = append(commands, fmt.Sprintf("%s %s %s", modeStr, file, c.Regex.Serialize())) } return diff --git a/internal/regex/regex.go b/internal/regex/regex.go index 707cb48..f668c38 100644 --- a/internal/regex/regex.go +++ b/internal/regex/regex.go @@ -39,6 +39,10 @@ func New(regexStr string, flag Flag) (Regex, error) { } func new(regexStr string, flags []Flag) (Regex, error) { + if len(flags) == 0 { + flags = append(flags, Default) + } + r := Regex{ regexStr: regexStr, flags: flags, -- cgit v1.2.3