chore: Fix linter findings for `revive:unused-receiver` in `agent`, `cmd`, `config`, `internal`, `metric`, `migrations`, `models`, `testutils` and `tools` (#16340)

This commit is contained in:
Paweł Żak 2025-01-15 20:58:58 +01:00 committed by GitHub
parent 878646a2c4
commit 4e7821a4fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 100 additions and 138 deletions

View File

@ -143,7 +143,7 @@ func TestAddTrackingMetricGroupEmpty(t *testing.T) {
type TestMetricMaker struct { type TestMetricMaker struct {
} }
func (tm *TestMetricMaker) Name() string { func (*TestMetricMaker) Name() string {
return "TestPlugin" return "TestPlugin"
} }
@ -151,10 +151,10 @@ func (tm *TestMetricMaker) LogName() string {
return tm.Name() return tm.Name()
} }
func (tm *TestMetricMaker) MakeMetric(metric telegraf.Metric) telegraf.Metric { func (*TestMetricMaker) MakeMetric(metric telegraf.Metric) telegraf.Metric {
return metric return metric
} }
func (tm *TestMetricMaker) Log() telegraf.Logger { func (*TestMetricMaker) Log() telegraf.Logger {
return logger.New("TestPlugin", "test", "") return logger.New("TestPlugin", "test", "")
} }

View File

@ -340,10 +340,7 @@ func (a *Agent) initPersister() error {
return nil return nil
} }
func (a *Agent) startInputs( func (*Agent) startInputs(dst chan<- telegraf.Metric, inputs []*models.RunningInput) (*inputUnit, error) {
dst chan<- telegraf.Metric,
inputs []*models.RunningInput,
) (*inputUnit, error) {
log.Printf("D! [agent] Starting service inputs") log.Printf("D! [agent] Starting service inputs")
unit := &inputUnit{ unit := &inputUnit{
@ -447,13 +444,9 @@ func (a *Agent) runInputs(
log.Printf("D! [agent] Input channel closed") log.Printf("D! [agent] Input channel closed")
} }
// testStartInputs is a variation of startInputs for use in --test and --once // testStartInputs is a variation of startInputs for use in --test and --once mode.
// mode. It differs by logging Start errors and returning only plugins // It differs by logging Start errors and returning only plugins successfully started.
// successfully started. func (*Agent) testStartInputs(dst chan<- telegraf.Metric, inputs []*models.RunningInput) *inputUnit {
func (a *Agent) testStartInputs(
dst chan<- telegraf.Metric,
inputs []*models.RunningInput,
) *inputUnit {
log.Printf("D! [agent] Starting service inputs") log.Printf("D! [agent] Starting service inputs")
unit := &inputUnit{ unit := &inputUnit{
@ -582,14 +575,8 @@ func (a *Agent) gatherLoop(
} }
} }
// gatherOnce runs the input's Gather function once, logging a warning each // gatherOnce runs the input's Gather function once, logging a warning each interval it fails to complete before.
// interval it fails to complete before. func (*Agent) gatherOnce(acc telegraf.Accumulator, input *models.RunningInput, ticker Ticker, interval time.Duration) error {
func (a *Agent) gatherOnce(
acc telegraf.Accumulator,
input *models.RunningInput,
ticker Ticker,
interval time.Duration,
) error {
done := make(chan error) done := make(chan error)
go func() { go func() {
defer panicRecover(input) defer panicRecover(input)
@ -617,12 +604,8 @@ func (a *Agent) gatherOnce(
} }
} }
// startProcessors sets up the processor chain and calls Start on all // startProcessors sets up the processor chain and calls Start on all processors. If an error occurs any started processors are Stopped.
// processors. If an error occurs any started processors are Stopped. func (*Agent) startProcessors(dst chan<- telegraf.Metric, runningProcessors models.RunningProcessors) (chan<- telegraf.Metric, []*processorUnit, error) {
func (a *Agent) startProcessors(
dst chan<- telegraf.Metric,
runningProcessors models.RunningProcessors,
) (chan<- telegraf.Metric, []*processorUnit, error) {
var src chan telegraf.Metric var src chan telegraf.Metric
units := make([]*processorUnit, 0, len(runningProcessors)) units := make([]*processorUnit, 0, len(runningProcessors))
// The processor chain is constructed from the output side starting from // The processor chain is constructed from the output side starting from
@ -657,11 +640,8 @@ func (a *Agent) startProcessors(
return src, units, nil return src, units, nil
} }
// runProcessors begins processing metrics and runs until the source channel is // runProcessors begins processing metrics and runs until the source channel is closed and all metrics have been written.
// closed and all metrics have been written. func (*Agent) runProcessors(units []*processorUnit) {
func (a *Agent) runProcessors(
units []*processorUnit,
) {
var wg sync.WaitGroup var wg sync.WaitGroup
for _, unit := range units { for _, unit := range units {
wg.Add(1) wg.Add(1)
@ -684,7 +664,7 @@ func (a *Agent) runProcessors(
} }
// startAggregators sets up the aggregator unit and returns the source channel. // startAggregators sets up the aggregator unit and returns the source channel.
func (a *Agent) startAggregators(aggC, outputC chan<- telegraf.Metric, aggregators []*models.RunningAggregator) (chan<- telegraf.Metric, *aggregatorUnit) { func (*Agent) startAggregators(aggC, outputC chan<- telegraf.Metric, aggregators []*models.RunningAggregator) (chan<- telegraf.Metric, *aggregatorUnit) {
src := make(chan telegraf.Metric, 100) src := make(chan telegraf.Metric, 100)
unit := &aggregatorUnit{ unit := &aggregatorUnit{
src: src, src: src,
@ -771,11 +751,7 @@ func updateWindow(start time.Time, roundInterval bool, period time.Duration) (ti
} }
// push runs the push for a single aggregator every period. // push runs the push for a single aggregator every period.
func (a *Agent) push( func (*Agent) push(ctx context.Context, aggregator *models.RunningAggregator, acc telegraf.Accumulator) {
ctx context.Context,
aggregator *models.RunningAggregator,
acc telegraf.Accumulator,
) {
for { for {
// Ensures that Push will be called for each period, even if it has // Ensures that Push will be called for each period, even if it has
// already elapsed before this function is called. This is guaranteed // already elapsed before this function is called. This is guaranteed
@ -824,7 +800,7 @@ func (a *Agent) startOutputs(
} }
// connectOutput connects to all outputs. // connectOutput connects to all outputs.
func (a *Agent) connectOutput(ctx context.Context, output *models.RunningOutput) error { func (*Agent) connectOutput(ctx context.Context, output *models.RunningOutput) error {
log.Printf("D! [agent] Attempting connection to [%s]", output.LogName()) log.Printf("D! [agent] Attempting connection to [%s]", output.LogName())
if err := output.Connect(); err != nil { if err := output.Connect(); err != nil {
log.Printf("E! [agent] Failed to connect to [%s], retrying in 15s, error was %q", output.LogName(), err) log.Printf("E! [agent] Failed to connect to [%s], retrying in 15s, error was %q", output.LogName(), err)
@ -938,13 +914,8 @@ func (a *Agent) flushLoop(
} }
} }
// flushOnce runs the output's Write function once, logging a warning each // flushOnce runs the output's Write function once, logging a warning each interval it fails to complete before the flush interval elapses.
// interval it fails to complete before the flush interval elapses. func (*Agent) flushOnce(output *models.RunningOutput, ticker Ticker, writeFunc func() error) error {
func (a *Agent) flushOnce(
output *models.RunningOutput,
ticker Ticker,
writeFunc func() error,
) error {
done := make(chan error) done := make(chan error)
go func() { go func() {
done <- writeFunc() done <- writeFunc()
@ -963,12 +934,8 @@ func (a *Agent) flushOnce(
} }
} }
// flushBatch runs the output's Write function once Unlike flushOnce the // flushBatch runs the output's Write function once Unlike flushOnce the interval elapsing is not considered during these flushes.
// interval elapsing is not considered during these flushes. func (*Agent) flushBatch(output *models.RunningOutput, writeFunc func() error) error {
func (a *Agent) flushBatch(
output *models.RunningOutput,
writeFunc func() error,
) error {
err := writeFunc() err := writeFunc()
output.LogBufferStatus() output.LogBufferStatus()
return err return err

View File

@ -53,11 +53,11 @@ func (m *MockTelegraf) Init(_ <-chan error, _ Filters, g GlobalFlags, w WindowFl
m.WindowFlags = w m.WindowFlags = w
} }
func (m *MockTelegraf) Run() error { func (*MockTelegraf) Run() error {
return nil return nil
} }
func (m *MockTelegraf) ListSecretStores() ([]string, error) { func (*MockTelegraf) ListSecretStores() ([]string, error) {
ids := make([]string, 0, len(secrets)) ids := make([]string, 0, len(secrets))
for k := range secrets { for k := range secrets {
ids = append(ids, k) ids = append(ids, k)
@ -65,7 +65,7 @@ func (m *MockTelegraf) ListSecretStores() ([]string, error) {
return ids, nil return ids, nil
} }
func (m *MockTelegraf) GetSecretStore(id string) (telegraf.SecretStore, error) { func (*MockTelegraf) GetSecretStore(id string) (telegraf.SecretStore, error) {
v, found := secrets[id] v, found := secrets[id]
if !found { if !found {
return nil, errors.New("unknown secret store") return nil, errors.New("unknown secret store")
@ -78,11 +78,11 @@ type MockSecretStore struct {
Secrets map[string][]byte Secrets map[string][]byte
} }
func (s *MockSecretStore) Init() error { func (*MockSecretStore) Init() error {
return nil return nil
} }
func (s *MockSecretStore) SampleConfig() string { func (*MockSecretStore) SampleConfig() string {
return "I'm just a dummy" return "I'm just a dummy"
} }
@ -149,7 +149,7 @@ func (m *MockServer) Start(_ string) {
m.Address = "localhost:6060" m.Address = "localhost:6060"
} }
func (m *MockServer) ErrChan() <-chan error { func (*MockServer) ErrChan() <-chan error {
return nil return nil
} }

View File

@ -254,7 +254,7 @@ func (t *Telegraf) watchLocalConfig(ctx context.Context, signals chan os.Signal,
signals <- syscall.SIGHUP signals <- syscall.SIGHUP
} }
func (t *Telegraf) watchRemoteConfigs(ctx context.Context, signals chan os.Signal, interval time.Duration, remoteConfigs []string) { func (*Telegraf) watchRemoteConfigs(ctx context.Context, signals chan os.Signal, interval time.Duration, remoteConfigs []string) {
configs := strings.Join(remoteConfigs, ", ") configs := strings.Join(remoteConfigs, ", ")
log.Printf("I! Remote config watcher started for: %s\n", configs) log.Printf("I! Remote config watcher started for: %s\n", configs)

View File

@ -1659,7 +1659,7 @@ func (c *Config) resetMissingTomlFieldTracker() {
c.toml.MissingField = c.missingTomlField c.toml.MissingField = c.missingTomlField
} }
func (c *Config) getFieldString(tbl *ast.Table, fieldName string) string { func (*Config) getFieldString(tbl *ast.Table, fieldName string) string {
if node, ok := tbl.Fields[fieldName]; ok { if node, ok := tbl.Fields[fieldName]; ok {
if kv, ok := node.(*ast.KeyValue); ok { if kv, ok := node.(*ast.KeyValue); ok {
if str, ok := kv.Value.(*ast.String); ok { if str, ok := kv.Value.(*ast.String); ok {

View File

@ -1198,10 +1198,10 @@ type MockupInputPluginParserNew struct {
ParserFunc telegraf.ParserFunc ParserFunc telegraf.ParserFunc
} }
func (m *MockupInputPluginParserNew) SampleConfig() string { func (*MockupInputPluginParserNew) SampleConfig() string {
return "Mockup old parser test plugin" return "Mockup old parser test plugin"
} }
func (m *MockupInputPluginParserNew) Gather(_ telegraf.Accumulator) error { func (*MockupInputPluginParserNew) Gather(telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupInputPluginParserNew) SetParser(parser telegraf.Parser) { func (m *MockupInputPluginParserNew) SetParser(parser telegraf.Parser) {
@ -1231,10 +1231,10 @@ type MockupInputPlugin struct {
parser telegraf.Parser parser telegraf.Parser
} }
func (m *MockupInputPlugin) SampleConfig() string { func (*MockupInputPlugin) SampleConfig() string {
return "Mockup test input plugin" return "Mockup test input plugin"
} }
func (m *MockupInputPlugin) Gather(_ telegraf.Accumulator) error { func (*MockupInputPlugin) Gather(telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupInputPlugin) SetParser(parser telegraf.Parser) { func (m *MockupInputPlugin) SetParser(parser telegraf.Parser) {
@ -1246,10 +1246,10 @@ type MockupInputPluginParserFunc struct {
parserFunc telegraf.ParserFunc parserFunc telegraf.ParserFunc
} }
func (m *MockupInputPluginParserFunc) SampleConfig() string { func (*MockupInputPluginParserFunc) SampleConfig() string {
return "Mockup test input plugin" return "Mockup test input plugin"
} }
func (m *MockupInputPluginParserFunc) Gather(_ telegraf.Accumulator) error { func (*MockupInputPluginParserFunc) Gather(telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupInputPluginParserFunc) SetParserFunc(pf telegraf.ParserFunc) { func (m *MockupInputPluginParserFunc) SetParserFunc(pf telegraf.ParserFunc) {
@ -1261,10 +1261,10 @@ type MockupInputPluginParserOnly struct {
parser telegraf.Parser parser telegraf.Parser
} }
func (m *MockupInputPluginParserOnly) SampleConfig() string { func (*MockupInputPluginParserOnly) SampleConfig() string {
return "Mockup test input plugin" return "Mockup test input plugin"
} }
func (m *MockupInputPluginParserOnly) Gather(_ telegraf.Accumulator) error { func (*MockupInputPluginParserOnly) Gather(telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupInputPluginParserOnly) SetParser(p telegraf.Parser) { func (m *MockupInputPluginParserOnly) SetParser(p telegraf.Parser) {
@ -1277,18 +1277,18 @@ type MockupProcessorPluginParser struct {
ParserFunc telegraf.ParserFunc ParserFunc telegraf.ParserFunc
} }
func (m *MockupProcessorPluginParser) Start(_ telegraf.Accumulator) error { func (*MockupProcessorPluginParser) Start(telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupProcessorPluginParser) Stop() { func (*MockupProcessorPluginParser) Stop() {
} }
func (m *MockupProcessorPluginParser) SampleConfig() string { func (*MockupProcessorPluginParser) SampleConfig() string {
return "Mockup test processor plugin with parser" return "Mockup test processor plugin with parser"
} }
func (m *MockupProcessorPluginParser) Apply(_ ...telegraf.Metric) []telegraf.Metric { func (*MockupProcessorPluginParser) Apply(...telegraf.Metric) []telegraf.Metric {
return nil return nil
} }
func (m *MockupProcessorPluginParser) Add(_ telegraf.Metric, _ telegraf.Accumulator) error { func (*MockupProcessorPluginParser) Add(telegraf.Metric, telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupProcessorPluginParser) SetParser(parser telegraf.Parser) { func (m *MockupProcessorPluginParser) SetParser(parser telegraf.Parser) {
@ -1304,15 +1304,10 @@ type MockupProcessorPlugin struct {
state []uint64 state []uint64
} }
func (m *MockupProcessorPlugin) Start(_ telegraf.Accumulator) error { func (*MockupProcessorPlugin) SampleConfig() string {
return nil
}
func (m *MockupProcessorPlugin) Stop() {
}
func (m *MockupProcessorPlugin) SampleConfig() string {
return "Mockup test processor plugin with parser" return "Mockup test processor plugin with parser"
} }
func (m *MockupProcessorPlugin) Apply(in ...telegraf.Metric) []telegraf.Metric { func (*MockupProcessorPlugin) Apply(in ...telegraf.Metric) []telegraf.Metric {
out := make([]telegraf.Metric, 0, len(in)) out := make([]telegraf.Metric, 0, len(in))
for _, m := range in { for _, m := range in {
m.AddTag("processed", "yes") m.AddTag("processed", "yes")
@ -1338,18 +1333,18 @@ type MockupProcessorPluginParserOnly struct {
Parser telegraf.Parser Parser telegraf.Parser
} }
func (m *MockupProcessorPluginParserOnly) Start(_ telegraf.Accumulator) error { func (*MockupProcessorPluginParserOnly) Start(telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupProcessorPluginParserOnly) Stop() { func (*MockupProcessorPluginParserOnly) Stop() {
} }
func (m *MockupProcessorPluginParserOnly) SampleConfig() string { func (*MockupProcessorPluginParserOnly) SampleConfig() string {
return "Mockup test processor plugin with parser" return "Mockup test processor plugin with parser"
} }
func (m *MockupProcessorPluginParserOnly) Apply(_ ...telegraf.Metric) []telegraf.Metric { func (*MockupProcessorPluginParserOnly) Apply(...telegraf.Metric) []telegraf.Metric {
return nil return nil
} }
func (m *MockupProcessorPluginParserOnly) Add(_ telegraf.Metric, _ telegraf.Accumulator) error { func (*MockupProcessorPluginParserOnly) Add(telegraf.Metric, telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupProcessorPluginParserOnly) SetParser(parser telegraf.Parser) { func (m *MockupProcessorPluginParserOnly) SetParser(parser telegraf.Parser) {
@ -1361,18 +1356,18 @@ type MockupProcessorPluginParserFunc struct {
Parser telegraf.ParserFunc Parser telegraf.ParserFunc
} }
func (m *MockupProcessorPluginParserFunc) Start(_ telegraf.Accumulator) error { func (*MockupProcessorPluginParserFunc) Start(telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupProcessorPluginParserFunc) Stop() { func (*MockupProcessorPluginParserFunc) Stop() {
} }
func (m *MockupProcessorPluginParserFunc) SampleConfig() string { func (*MockupProcessorPluginParserFunc) SampleConfig() string {
return "Mockup test processor plugin with parser" return "Mockup test processor plugin with parser"
} }
func (m *MockupProcessorPluginParserFunc) Apply(_ ...telegraf.Metric) []telegraf.Metric { func (*MockupProcessorPluginParserFunc) Apply(...telegraf.Metric) []telegraf.Metric {
return nil return nil
} }
func (m *MockupProcessorPluginParserFunc) Add(_ telegraf.Metric, _ telegraf.Accumulator) error { func (*MockupProcessorPluginParserFunc) Add(telegraf.Metric, telegraf.Accumulator) error {
return nil return nil
} }
func (m *MockupProcessorPluginParserFunc) SetParserFunc(pf telegraf.ParserFunc) { func (m *MockupProcessorPluginParserFunc) SetParserFunc(pf telegraf.ParserFunc) {
@ -1389,16 +1384,16 @@ type MockupOutputPlugin struct {
tls.ClientConfig tls.ClientConfig
} }
func (m *MockupOutputPlugin) Connect() error { func (*MockupOutputPlugin) Connect() error {
return nil return nil
} }
func (m *MockupOutputPlugin) Close() error { func (*MockupOutputPlugin) Close() error {
return nil return nil
} }
func (m *MockupOutputPlugin) SampleConfig() string { func (*MockupOutputPlugin) SampleConfig() string {
return "Mockup test output plugin" return "Mockup test output plugin"
} }
func (m *MockupOutputPlugin) Write(_ []telegraf.Metric) error { func (*MockupOutputPlugin) Write([]telegraf.Metric) error {
return nil return nil
} }
@ -1474,11 +1469,11 @@ func (m *MockupStatePlugin) SetState(state interface{}) error {
return nil return nil
} }
func (m *MockupStatePlugin) SampleConfig() string { func (*MockupStatePlugin) SampleConfig() string {
return "Mockup test plugin" return "Mockup test plugin"
} }
func (m *MockupStatePlugin) Gather(_ telegraf.Accumulator) error { func (*MockupStatePlugin) Gather(telegraf.Accumulator) error {
return nil return nil
} }

View File

@ -252,7 +252,7 @@ func (c *Config) CollectDeprecationInfos(inFilter, outFilter, aggFilter, procFil
return infos return infos
} }
func (c *Config) PrintDeprecationList(plugins []PluginDeprecationInfo) { func (*Config) PrintDeprecationList(plugins []PluginDeprecationInfo) {
sort.Slice(plugins, func(i, j int) bool { return plugins[i].Name < plugins[j].Name }) sort.Slice(plugins, func(i, j int) bool { return plugins[i].Name < plugins[j].Name })
for _, plugin := range plugins { for _, plugin := range plugins {

View File

@ -122,7 +122,7 @@ func (c *protectedSecretContainer) Buffer() (SecretBuffer, error) {
return &lockedBuffer{lockbuf}, nil return &lockedBuffer{lockbuf}, nil
} }
func (c *protectedSecretContainer) AsBuffer(secret []byte) SecretBuffer { func (*protectedSecretContainer) AsBuffer(secret []byte) SecretBuffer {
return &lockedBuffer{memguard.NewBufferFromBytes(secret)} return &lockedBuffer{memguard.NewBufferFromBytes(secret)}
} }

View File

@ -801,7 +801,7 @@ type MockupSecretStore struct {
Dynamic bool Dynamic bool
} }
func (s *MockupSecretStore) Init() error { func (*MockupSecretStore) Init() error {
return nil return nil
} }
func (*MockupSecretStore) SampleConfig() string { func (*MockupSecretStore) SampleConfig() string {

View File

@ -33,7 +33,7 @@ func (lb *unlockedBuffer) Size() int {
return len(lb.content) return len(lb.content)
} }
func (lb *unlockedBuffer) Grow(_ int) { func (*unlockedBuffer) Grow(int) {
// The underlying byte-buffer will grow dynamically // The underlying byte-buffer will grow dynamically
} }
@ -85,7 +85,7 @@ func (c *unprotectedSecretContainer) Buffer() (SecretBuffer, error) {
return newUnlockedBuffer(c.buf.content), nil return newUnlockedBuffer(c.buf.content), nil
} }
func (c *unprotectedSecretContainer) AsBuffer(secret []byte) SecretBuffer { func (*unprotectedSecretContainer) AsBuffer(secret []byte) SecretBuffer {
return &unlockedBuffer{secret} return &unlockedBuffer{secret}
} }

View File

@ -55,7 +55,7 @@ func (g *gosmiTranslator) SnmpTable(oid string) (
return mibName, oidNum, oidText, fields, nil return mibName, oidNum, oidText, fields, nil
} }
func (g *gosmiTranslator) SnmpFormatEnum(oid string, value interface{}, full bool) (string, error) { func (*gosmiTranslator) SnmpFormatEnum(oid string, value interface{}, full bool) (string, error) {
if value == nil { if value == nil {
return "", nil return "", nil
} }
@ -80,7 +80,7 @@ func (g *gosmiTranslator) SnmpFormatEnum(oid string, value interface{}, full boo
return v.String(), nil return v.String(), nil
} }
func (g *gosmiTranslator) SnmpFormatDisplayHint(oid string, value interface{}) (string, error) { func (*gosmiTranslator) SnmpFormatDisplayHint(oid string, value interface{}) (string, error) {
if value == nil { if value == nil {
return "", nil return "", nil
} }

View File

@ -263,10 +263,10 @@ func (n *netsnmpTranslator) snmpTranslateCall(oid string) (mibName string, oidNu
return mibName, oidNum, oidText, conversion, nil return mibName, oidNum, oidText, conversion, nil
} }
func (n *netsnmpTranslator) SnmpFormatEnum(_ string, _ interface{}, _ bool) (string, error) { func (*netsnmpTranslator) SnmpFormatEnum(string, interface{}, bool) (string, error) {
return "", errors.New("not implemented in netsnmp translator") return "", errors.New("not implemented in netsnmp translator")
} }
func (n *netsnmpTranslator) SnmpFormatDisplayHint(_ string, _ interface{}) (string, error) { func (*netsnmpTranslator) SnmpFormatDisplayHint(string, interface{}) (string, error) {
return "", errors.New("not implemented in netsnmp translator") return "", errors.New("not implemented in netsnmp translator")
} }

View File

@ -42,7 +42,7 @@ func (tsc *testSNMPConnection) Walk(oid string, wf gosnmp.WalkFunc) error {
} }
return nil return nil
} }
func (tsc *testSNMPConnection) Reconnect() error { func (*testSNMPConnection) Reconnect() error {
return nil return nil
} }

View File

@ -278,13 +278,13 @@ func (m *metric) HashID() uint64 {
return h.Sum64() return h.Sum64()
} }
func (m *metric) Accept() { func (*metric) Accept() {
} }
func (m *metric) Reject() { func (*metric) Reject() {
} }
func (m *metric) Drop() { func (*metric) Drop() {
} }
// Convert field to a supported type or nil if inconvertible // Convert field to a supported type or nil if inconvertible

View File

@ -88,9 +88,9 @@ type MockupInputPlugin struct {
Timeout config.Duration `toml:"timeout"` Timeout config.Duration `toml:"timeout"`
} }
func (m *MockupInputPlugin) SampleConfig() string { func (*MockupInputPlugin) SampleConfig() string {
return "Mockup test input plugin" return "Mockup test input plugin"
} }
func (m *MockupInputPlugin) Gather(_ telegraf.Accumulator) error { func (*MockupInputPlugin) Gather(telegraf.Accumulator) error {
return nil return nil
} }

View File

@ -41,7 +41,7 @@ func (tx *Transaction) AcceptAll() {
} }
} }
func (tx *Transaction) KeepAll() {} func (*Transaction) KeepAll() {}
func (tx *Transaction) InferKeep() []int { func (tx *Transaction) InferKeep() []int {
used := make([]bool, len(tx.Batch)) used := make([]bool, len(tx.Batch))

View File

@ -119,7 +119,7 @@ func (b *MemoryBuffer) EndTransaction(tx *Transaction) {
b.BufferSize.Set(int64(b.length())) b.BufferSize.Set(int64(b.length()))
} }
func (b *MemoryBuffer) Close() error { func (*MemoryBuffer) Close() error {
return nil return nil
} }

View File

@ -243,7 +243,7 @@ type mockAggregator struct {
sum int64 sum int64
} }
func (t *mockAggregator) SampleConfig() string { func (*mockAggregator) SampleConfig() string {
return "" return ""
} }

View File

@ -102,7 +102,7 @@ type InputConfig struct {
AlwaysIncludeGlobalTags bool AlwaysIncludeGlobalTags bool
} }
func (r *RunningInput) metricFiltered(metric telegraf.Metric) { func (*RunningInput) metricFiltered(metric telegraf.Metric) {
metric.Drop() metric.Drop()
} }

View File

@ -489,10 +489,10 @@ func TestRunningInputMakeMetricWithGatherEndTimeSource(t *testing.T) {
type mockInput struct{} type mockInput struct{}
func (t *mockInput) SampleConfig() string { func (*mockInput) SampleConfig() string {
return "" return ""
} }
func (t *mockInput) Gather(_ telegraf.Accumulator) error { func (*mockInput) Gather(telegraf.Accumulator) error {
return nil return nil
} }

View File

@ -362,7 +362,7 @@ func (r *RunningOutput) writeMetrics(metrics []telegraf.Metric) error {
return err return err
} }
func (r *RunningOutput) updateTransaction(tx *Transaction, err error) { func (*RunningOutput) updateTransaction(tx *Transaction, err error) {
// No error indicates all metrics were written successfully // No error indicates all metrics were written successfully
if err == nil { if err == nil {
tx.AcceptAll() tx.AcceptAll()

View File

@ -54,7 +54,7 @@ func NewRunningProcessor(processor telegraf.StreamingProcessor, config *Processo
} }
} }
func (rp *RunningProcessor) metricFiltered(metric telegraf.Metric) { func (*RunningProcessor) metricFiltered(metric telegraf.Metric) {
metric.Drop() metric.Drop()
} }
@ -83,7 +83,7 @@ func (rp *RunningProcessor) LogName() string {
return logName("processors", rp.Config.Name, rp.Config.Alias) return logName("processors", rp.Config.Name, rp.Config.Alias)
} }
func (rp *RunningProcessor) MakeMetric(metric telegraf.Metric) telegraf.Metric { func (*RunningProcessor) MakeMetric(metric telegraf.Metric) telegraf.Metric {
return metric return metric
} }

View File

@ -212,7 +212,7 @@ type mockProcessor struct {
hasBeenInit bool hasBeenInit bool
} }
func (p *mockProcessor) SampleConfig() string { func (*mockProcessor) SampleConfig() string {
return "" return ""
} }

View File

@ -265,10 +265,10 @@ func (a *Accumulator) AddError(err error) {
a.Unlock() a.Unlock()
} }
func (a *Accumulator) SetPrecision(_ time.Duration) { func (*Accumulator) SetPrecision(time.Duration) {
} }
func (a *Accumulator) DisablePrecision() { func (*Accumulator) DisablePrecision() {
} }
func (a *Accumulator) Debug() bool { func (a *Accumulator) Debug() bool {
@ -756,17 +756,17 @@ func (a *Accumulator) BoolField(measurement, field string) (v, ok bool) {
// telegraf accumulator machinery. // telegraf accumulator machinery.
type NopAccumulator struct{} type NopAccumulator struct{}
func (n *NopAccumulator) AddFields(_ string, _ map[string]interface{}, _ map[string]string, _ ...time.Time) { func (*NopAccumulator) AddFields(string, map[string]interface{}, map[string]string, ...time.Time) {
} }
func (n *NopAccumulator) AddGauge(_ string, _ map[string]interface{}, _ map[string]string, _ ...time.Time) { func (*NopAccumulator) AddGauge(string, map[string]interface{}, map[string]string, ...time.Time) {
} }
func (n *NopAccumulator) AddCounter(_ string, _ map[string]interface{}, _ map[string]string, _ ...time.Time) { func (*NopAccumulator) AddCounter(string, map[string]interface{}, map[string]string, ...time.Time) {
} }
func (n *NopAccumulator) AddSummary(_ string, _ map[string]interface{}, _ map[string]string, _ ...time.Time) { func (*NopAccumulator) AddSummary(string, map[string]interface{}, map[string]string, ...time.Time) {
} }
func (n *NopAccumulator) AddHistogram(_ string, _ map[string]interface{}, _ map[string]string, _ ...time.Time) { func (*NopAccumulator) AddHistogram(string, map[string]interface{}, map[string]string, ...time.Time) {
} }
func (n *NopAccumulator) AddMetric(telegraf.Metric) {} func (*NopAccumulator) AddMetric(telegraf.Metric) {}
func (n *NopAccumulator) SetPrecision(_ time.Duration) {} func (*NopAccumulator) SetPrecision(time.Duration) {}
func (n *NopAccumulator) AddError(_ error) {} func (*NopAccumulator) AddError(error) {}
func (n *NopAccumulator) WithTracking(_ int) telegraf.TrackingAccumulator { return nil } func (*NopAccumulator) WithTracking(int) telegraf.TrackingAccumulator { return nil }

View File

@ -50,7 +50,7 @@ func (l *CaptureLogger) loga(level byte, args ...any) {
l.print(Entry{level, l.Name, fmt.Sprint(args...)}) l.print(Entry{level, l.Name, fmt.Sprint(args...)})
} }
func (l *CaptureLogger) Level() telegraf.LogLevel { func (*CaptureLogger) Level() telegraf.LogLevel {
return telegraf.Trace return telegraf.Trace
} }

View File

@ -52,15 +52,15 @@ func (p *pki) CACertPath() string {
return path.Join(p.keyPath, "cacert.pem") return path.Join(p.keyPath, "cacert.pem")
} }
func (p *pki) CipherSuite() string { func (*pki) CipherSuite() string {
return "TLS_RSA_WITH_3DES_EDE_CBC_SHA" return "TLS_RSA_WITH_3DES_EDE_CBC_SHA"
} }
func (p *pki) TLSMinVersion() string { func (*pki) TLSMinVersion() string {
return "TLS11" return "TLS11"
} }
func (p *pki) TLSMaxVersion() string { func (*pki) TLSMaxVersion() string {
return "TLS13" return "TLS13"
} }

View File

@ -21,7 +21,7 @@ type BytesBuffer struct {
*bytes.Buffer *bytes.Buffer
} }
func (b *BytesBuffer) Close() error { func (*BytesBuffer) Close() error {
return nil return nil
} }