package main import ( "fmt" "github.com/elastic/go-libaudit/v2" "github.com/elastic/go-libaudit/v2/auparse" "github.com/mohae/deepcopy" ) func receive(r *libaudit.AuditClient) error { defer wg.Done() defer close(rawChan) for { rawEvent, err := r.Receive(false) if err != nil { return fmt.Errorf("receive failed: %w", err) } // Messages from 1300-2999 are valid audit messages. if rawEvent.Type < auparse.AUDIT_USER_AUTH || rawEvent.Type > auparse.AUDIT_LAST_USER_MSG2 { continue } rawEventMessage := deepcopy.Copy(*rawEvent) rawChan <- rawEventMessage } }