Skip to content

Commit

Permalink
make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry committed Sep 21, 2023
1 parent d0a3c4a commit 4a092ae
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions libbeat/common/fmtstr/formatevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ type eventEvalContext struct {
}

var (
errMissingKeys = errors.New("missing keys")
errConvertString = errors.New("can not convert to string")
)

Expand Down Expand Up @@ -304,7 +303,7 @@ func (e *eventFieldCompiler) compileEventField(
ops []VariableOp,
) (FormatEvaler, error) {
if len(ops) > 1 {
return nil, errors.New("Too many format modifiers given")
return nil, errors.New("too many format modifiers given")
}

defaultValue := ""
Expand Down Expand Up @@ -348,34 +347,26 @@ func (e *eventFieldCompiler) compileTimestamp(
ops []VariableOp,
) (FormatEvaler, error) {
if expression[0] != '+' {
return nil, errors.New("No timestamp expression")
return nil, errors.New("no timestamp expression")
}

formatter, err := dtfmt.NewFormatter(expression[1:])
if err != nil {
return nil, fmt.Errorf("%v in timestamp expression", err)
return nil, fmt.Errorf("%w in timestamp expression", err)
}

e.timestamp = true
return &eventTimestampEvaler{formatter}, nil
}

func (e *eventFieldEvaler) Eval(c interface{}, out *bytes.Buffer) error {
type stringer interface {
String() string
}

ctx := c.(*eventEvalContext)
s := ctx.keys[e.index]
_, err := out.WriteString(s)
return err
}

func (e *defaultEventFieldEvaler) Eval(c interface{}, out *bytes.Buffer) error {
type stringer interface {
String() string
}

ctx := c.(*eventEvalContext)
s := ctx.keys[e.index]
if s == "" {
Expand All @@ -393,7 +384,7 @@ func (e *eventTimestampEvaler) Eval(c interface{}, out *bytes.Buffer) error {

func parseEventPath(field string) (string, error) {
field = strings.Trim(field, " \n\r\t")
var fields []string
fields := []string{}

for len(field) > 0 {
if field[0] != '[' {
Expand Down

0 comments on commit 4a092ae

Please sign in to comment.