mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-17 09:51:56 +00:00
Update serializableRegexp.go
This commit is contained in:
parent
76bb3db553
commit
1c4588a83c
@ -6,8 +6,6 @@ type SerializableRegexp struct {
|
||||
regexp.Regexp
|
||||
}
|
||||
|
||||
// CompileRegexToSerializableRegexp wraps the result of the standard library's
|
||||
// regexp.Compile, for easy (un)marshaling.
|
||||
func CompileRegexToSerializableRegexp(expr string) (*SerializableRegexp, error) {
|
||||
re, err := regexp.Compile(expr)
|
||||
if err != nil {
|
||||
@ -16,8 +14,7 @@ func CompileRegexToSerializableRegexp(expr string) (*SerializableRegexp, error)
|
||||
return &SerializableRegexp{*re}, nil
|
||||
}
|
||||
|
||||
// UnmarshalText satisfies the encoding.TextMarshaler interface,
|
||||
// also used by json.Unmarshal.
|
||||
// UnmarshalText is by json.Unmarshal.
|
||||
func (r *SerializableRegexp) UnmarshalText(text []byte) error {
|
||||
rr, err := CompileRegexToSerializableRegexp(string(text))
|
||||
if err != nil {
|
||||
@ -27,8 +24,7 @@ func (r *SerializableRegexp) UnmarshalText(text []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText satisfies the encoding.TextMarshaler interface,
|
||||
// also used by json.Marshal.
|
||||
// MarshalText is used by json.Marshal.
|
||||
func (r *SerializableRegexp) MarshalText() ([]byte, error) {
|
||||
return []byte(r.String()), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user