Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "2"
run:
tests: true
linters:
enable:
- govet
- ineffassign
- staticcheck
- unused
- bodyclose
- gocognit
- dupl
- errcheck
- modernize
- errname
- errorlint
- prealloc

settings:
gocognit:
min-complexity: 15
dupl:
threshold: 100
modernize:
disable:
- plusbuild
errcheck:
exclude-functions:
- fmt.Fprintf
- (io.Closer).Close
- (*os.File).Close
- (*net.TCPConn).Close
- (*net.TCPListener).Close
- (*bytes.Buffer).Write
- (*strings.Builder).WriteString
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ check:
go test -v ./...
go test -race ./...

lint:
golangci-lint run --timeout 5m ./...
4 changes: 2 additions & 2 deletions statsfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func writeStats(dir, filename string, st procfs.CPUStat) error {
err = je.Encode(stats{st, n})
if err != nil {
newFile.Close()
os.Remove(newFile.Name())
_ = os.Remove(newFile.Name())
return err
}

err = newFile.Close()
if err != nil {
os.Remove(newFile.Name())
_ = os.Remove(newFile.Name())
return err
}

Expand Down
9 changes: 5 additions & 4 deletions usageplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ func (u LinuxUsagePlugin) gaugeNetMetrics(pf procfs.FS) (map[string]float64, err
if err != nil {
return res, err
}
if psnmp.Tcp.ActiveOpens != nil {
res["active"] = *psnmp.Tcp.ActiveOpens
tcp := psnmp.Tcp
if tcp.ActiveOpens != nil {
res["active"] = *tcp.ActiveOpens
}
if psnmp.Tcp.PassiveOpens != nil {
res["passive"] = *psnmp.Tcp.PassiveOpens
if tcp.PassiveOpens != nil {
res["passive"] = *tcp.PassiveOpens
}
if pnetstat.ListenOverflows != nil {
res["overflows"] = *pnetstat.ListenOverflows
Expand Down
Loading