Files
kured/cmd/kured/pflags.go
T
Jean-Philippe Evrard 231888e58a Use RegexpValue in plags
This will remove double pointers, and be explicit about the
type we are using.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-19 15:51:04 +02:00

31 lines
455 B
Go

package main
import (
"regexp"
)
type regexpValue struct {
*regexp.Regexp
}
func (rev *regexpValue) String() string {
if rev.Regexp == nil {
return ""
}
return rev.Regexp.String()
}
func (rev *regexpValue) Set(s string) error {
value, err := regexp.Compile(s)
if err != nil {
return err
}
rev.Regexp = value
return nil
}
// Type method returns the type of the flag as a string
func (rev *regexpValue) Type() string {
return "regexp"
}