From 34ae901ff30a32d9aef33bfe25561ff2f685cb0c Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 30 Nov 2018 15:26:05 +0700 Subject: all: fix warning from linter --- Makefile | 2 +- cmd/haminer/main.go | 2 +- halog.go | 12 ++++-------- influxdb.go | 2 +- udppacket.go | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 3dad251..6302c47 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ build: go build -v ./cmd/haminer lint: - -golangci-lint run ./... + -golangci-lint run --enable-all ./... install: build lint go install -v ./cmd/haminer diff --git a/cmd/haminer/main.go b/cmd/haminer/main.go index b457070..578ccd4 100644 --- a/cmd/haminer/main.go +++ b/cmd/haminer/main.go @@ -57,7 +57,7 @@ func initConfig() (cfg *haminer.Config) { cfg.InfluxAPIWrite = flagInfluxAPIWrite } - return + return cfg } func main() { diff --git a/halog.go b/halog.go index 8d25fd2..490540d 100644 --- a/halog.go +++ b/halog.go @@ -11,16 +11,12 @@ import ( "time" ) -var ( - timestampLayout = "2/Jan/2006:15:04:05.000" -) - // // Halog contains the mapping of haproxy HTTP log format to Go struct. // // Reference: https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#8.2.3 // -type Halog struct { +type Halog struct { // nolint: maligned Timestamp time.Time ClientIP string @@ -248,7 +244,7 @@ func (halog *Halog) parseHTTP(in []byte) (ok bool) { halog.HTTPProto, ok = parseToString(in, '"') - return + return ok } // @@ -283,7 +279,7 @@ func (halog *Halog) Parse(in []byte, reqHeaders []string) (ok bool) { return } - halog.Timestamp, err = time.Parse(timestampLayout, ts) + halog.Timestamp, err = time.Parse("2/Jan/2006:15:04:05.000", ts) if err != nil { return false } @@ -366,7 +362,7 @@ func (halog *Halog) Parse(in []byte, reqHeaders []string) (ok bool) { in = in[1:] ok = halog.parseHTTP(in) - return + return ok } // diff --git a/influxdb.go b/influxdb.go index d266100..badadbe 100644 --- a/influxdb.go +++ b/influxdb.go @@ -153,5 +153,5 @@ func (cl *InfluxdbClient) write(halogs []*Halog) (err error) { } } - return + return nil } diff --git a/udppacket.go b/udppacket.go index c7b017b..8cecfb0 100644 --- a/udppacket.go +++ b/udppacket.go @@ -30,8 +30,8 @@ func NewUDPPacket(size uint32) (p *UDPPacket) { } // -// Reset will set the content of packet data to zero, so it can be used agains -// on Read(). +// Reset will set the content of packet data to zero, so it can be used +// against on Read(). // func (p *UDPPacket) Reset() { p.Bytes[0] = 0 -- cgit v1.3