From 7c1077606450ee02d9b66593999fad0e0a8faecb Mon Sep 17 00:00:00 2001 From: Erik Schweller Date: Tue, 8 Jun 2021 15:43:19 -0400 Subject: [PATCH] Go report corrections (#939) * A few misspell corrections * apply 'gofmt -s' --- capture/doc.go | 2 +- capture/dump.go | 2 +- capture/sock_linux.go | 2 +- input_file.go | 8 ++++---- input_file_test.go | 18 +++++++++--------- kafka.go | 3 +-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/capture/doc.go b/capture/doc.go index a22519c..65c05e4 100644 --- a/capture/doc.go +++ b/capture/doc.go @@ -22,7 +22,7 @@ if err := listener.Listen(context.Background(), handler); err != nil { // handle error } // or -errCh := listener.ListenBackground(context.Background(), handler) // runs in the backgorund +errCh := listener.ListenBackground(context.Background(), handler) // runs in the background select { case err := <- errCh: // handle error diff --git a/capture/dump.go b/capture/dump.go index 640123d..a4974f2 100644 --- a/capture/dump.go +++ b/capture/dump.go @@ -54,7 +54,7 @@ func NewWriterNanos(w io.Writer) *Writer { // NewWriter returns a new writer object, for writing packet data out // to the given writer. If this is a new empty writer (as opposed to // an append), you must call WriteFileHeader before WritePacket. -// Packet timestamps are written witn microsecond precision. +// Packet timestamps are written with microsecond precision. // // // Write a new file: // f, _ := os.Create("/tmp/file.pcap") diff --git a/capture/sock_linux.go b/capture/sock_linux.go index 55dcccd..00c591e 100644 --- a/capture/sock_linux.go +++ b/capture/sock_linux.go @@ -217,7 +217,7 @@ func (sock *SockRaw) SetBPFFilter(expr string) error { return unix.SetsockoptSockFprog(sock.fd, unix.SOL_SOCKET, unix.SO_ATTACH_FILTER, fprog) } -// SetPromiscuous sets promiscous mode to the required value. for better result capture on all interfaces instead. +// SetPromiscuous sets promiscuous mode to the required value. for better result capture on all interfaces instead. // If it is enabled, traffic not destined for the interface will also be captured. func (sock *SockRaw) SetPromiscuous(b bool) error { sock.mu.Lock() diff --git a/input_file.go b/input_file.go index 681680a..a039d9c 100644 --- a/input_file.go +++ b/input_file.go @@ -162,10 +162,10 @@ func (i *FileInput) init() (err error) { for _, c := range resp.Contents { matches = append(matches, "s3://"+bucket+"/"+(*c.Key)) } - } else if matches, err = filepath.Glob(i.path); err != nil{ - Debug(0, "[INPUT-FILE] Wrong file pattern", i.path, err) - return - + } else if matches, err = filepath.Glob(i.path); err != nil { + Debug(0, "[INPUT-FILE] Wrong file pattern", i.path, err) + return + } if len(matches) == 0 { diff --git a/input_file_test.go b/input_file_test.go index fac5e01..91b9bcc 100644 --- a/input_file_test.go +++ b/input_file_test.go @@ -29,9 +29,9 @@ func TestInputFileWithGET(t *testing.T) { // The read request should match the original request if err != nil { t.Error(err) - } else if !expectedCaptureFile.PayloadsEqual(readPayloads){ - t.Error("Request read back from file should match") - + } else if !expectedCaptureFile.PayloadsEqual(readPayloads) { + t.Error("Request read back from file should match") + } } @@ -52,9 +52,9 @@ func TestInputFileWithPayloadLargerThan64Kb(t *testing.T) { // The read request should match the original request if err != nil { t.Error(err) - } else if !expectedCaptureFile.PayloadsEqual(readPayloads){ - t.Error("Request read back from file should match") - + } else if !expectedCaptureFile.PayloadsEqual(readPayloads) { + t.Error("Request read back from file should match") + } } @@ -80,9 +80,9 @@ func TestInputFileWithGETAndPOST(t *testing.T) { // The read requests should match the original request if err != nil { t.Error(err) - } else if !expectedCaptureFile.PayloadsEqual(readPayloads){ - t.Error("Request read back from file should match") - + } else if !expectedCaptureFile.PayloadsEqual(readPayloads) { + t.Error("Request read back from file should match") + } } diff --git a/kafka.go b/kafka.go index 6772345..46bc6c6 100644 --- a/kafka.go +++ b/kafka.go @@ -51,7 +51,6 @@ type KafkaMessage struct { ReqHeaders map[string]string `json:"Req_Headers,omitempty"` } - // NewTLSConfig loads TLS certificates func NewTLSConfig(clientCertFile, clientKeyFile, caCertFile string) (*tls.Config, error) { tlsConfig := tls.Config{} @@ -63,7 +62,7 @@ func NewTLSConfig(clientCertFile, clientKeyFile, caCertFile string) (*tls.Config return &tlsConfig, errors.New("missing TLS client certificate in kafka") } // Load client cert - if (clientCertFile != "") && (clientKeyFile != "") { + if (clientCertFile != "") && (clientKeyFile != "") { cert, err := tls.LoadX509KeyPair(clientCertFile, clientKeyFile) if err != nil { return &tlsConfig, err