func (r *Rule) Expression() Expression {
	var expr Expression
	for _, op := range AllowedOperators {
		if idx := strings.Index(r.Pattern, op); idx != -1 {
			expr = Expression{
				Op:    op,
				Field: r.Pattern[:idx],
				Value: r.Pattern[idx+len(op):],
			}
		}
	}
	return expr
}
Expression parses the rule pattern and builds an Expression object that can be passed to
marchers and used by policies that need access to the rule fields.
package policy
import (
	"fmt"
	"log"
	"os"
	"strings"
	"time"
)
var logger = log.New(os.Stdout, "", log.Lshortfile)
type Rule struct {
	Layer    string `json:"layer"`
	LType    string `json:"layer_type"`
	Pattern  string `json:"pattern"`
	disabled bool
}
var AllowedOperators = []string{"=", ">", "<", "in", "!=", ">=", "<="}
type Expression struct {
	Field string
	Value string
	Op    string
}
func (r *Rule) Match(r1 *Rule) (bool, bool) {
	if strings.Compare(r.Layer, r1.Layer) == 0 &&
		strings.Compare(r.LType, r1.LType) == 0 {
		return true, strings.Compare(r.Pattern, r1.Pattern) == 0
	}
	return false, false
}