chore: Fix linter findings for errname (#12253)
This commit is contained in:
parent
743e023f84
commit
e84df8983a
|
|
@ -2,14 +2,15 @@ linters:
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
# - telegraflinter
|
# - telegraflinter
|
||||||
- asciicheck
|
|
||||||
- asasalint
|
- asasalint
|
||||||
|
- asciicheck
|
||||||
- bidichk
|
- bidichk
|
||||||
- bodyclose
|
- bodyclose
|
||||||
- depguard
|
- depguard
|
||||||
- dogsled
|
- dogsled
|
||||||
- exportloopref
|
|
||||||
- errcheck
|
- errcheck
|
||||||
|
- errname
|
||||||
|
- exportloopref
|
||||||
- goprintffuncname
|
- goprintffuncname
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ const alphanum string = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrTimeout = errors.New("command timed out")
|
ErrTimeout = errors.New("command timed out")
|
||||||
ErrorNotImplemented = errors.New("not implemented yet")
|
ErrNotImplemented = errors.New("not implemented yet")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Set via LDFLAGS -X
|
// Set via LDFLAGS -X
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/influxdata/telegraf/internal"
|
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/disk"
|
"github.com/shirou/gopsutil/v3/disk"
|
||||||
"github.com/shirou/gopsutil/v3/host"
|
"github.com/shirou/gopsutil/v3/host"
|
||||||
"github.com/shirou/gopsutil/v3/mem"
|
"github.com/shirou/gopsutil/v3/mem"
|
||||||
"github.com/shirou/gopsutil/v3/net"
|
"github.com/shirou/gopsutil/v3/net"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf"
|
||||||
|
"github.com/influxdata/telegraf/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PS interface {
|
type PS interface {
|
||||||
|
|
@ -198,7 +198,7 @@ func (s *SystemPS) NetConntrack(perCPU bool) ([]net.ConntrackStat, error) {
|
||||||
|
|
||||||
func (s *SystemPS) DiskIO(names []string) (map[string]disk.IOCountersStat, error) {
|
func (s *SystemPS) DiskIO(names []string) (map[string]disk.IOCountersStat, error) {
|
||||||
m, err := disk.IOCounters(names...)
|
m, err := disk.IOCounters(names...)
|
||||||
if err == internal.ErrorNotImplemented {
|
if err == internal.ErrNotImplemented {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ type DatabaseNotFoundError struct {
|
||||||
Database string
|
Database string
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryResponse is the response body from the /query endpoint
|
// QueryResponseError is the response body from the /query endpoint
|
||||||
type QueryResponse struct {
|
type QueryResponseError struct {
|
||||||
Results []QueryResult `json:"results"`
|
Results []QueryResult `json:"results"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,19 +68,19 @@ type QueryResult struct {
|
||||||
Err string `json:"error,omitempty"`
|
Err string `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r QueryResponse) Error() string {
|
func (r QueryResponseError) Error() string {
|
||||||
if len(r.Results) > 0 {
|
if len(r.Results) > 0 {
|
||||||
return r.Results[0].Err
|
return r.Results[0].Err
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteResponse is the response body from the /write endpoint
|
// WriteResponseError is the response body from the /write endpoint
|
||||||
type WriteResponse struct {
|
type WriteResponseError struct {
|
||||||
Err string `json:"error,omitempty"`
|
Err string `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r WriteResponse) Error() string {
|
func (r WriteResponseError) Error() string {
|
||||||
return r.Err
|
return r.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ func (c *httpClient) CreateDatabase(ctx context.Context, database string) error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queryResp := &QueryResponse{}
|
queryResp := &QueryResponseError{}
|
||||||
dec := json.NewDecoder(body)
|
dec := json.NewDecoder(body)
|
||||||
err = dec.Decode(queryResp)
|
err = dec.Decode(queryResp)
|
||||||
|
|
||||||
|
|
@ -365,7 +365,7 @@ func (c *httpClient) writeBatch(ctx context.Context, db, rp string, metrics []te
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writeResp := &WriteResponse{}
|
writeResp := &WriteResponseError{}
|
||||||
dec := json.NewDecoder(body)
|
dec := json.NewDecoder(body)
|
||||||
|
|
||||||
var desc string
|
var desc string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue