diff --git a/main.go b/main.go index 98ead52..10f0465 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,6 @@ func main() { log.Error("can't create omq-memory.pprof", "error", err) } _ = pprof.WriteHeapProfile(memFile) - defer memFile.Close() + defer func() { _ = memFile.Close() }() } } diff --git a/pkg/amqp10_client/publisher.go b/pkg/amqp10_client/publisher.go index 7204504..b726db3 100644 --- a/pkg/amqp10_client/publisher.go +++ b/pkg/amqp10_client/publisher.go @@ -150,5 +150,5 @@ func (p Amqp10Publisher) Send() { func (p Amqp10Publisher) Stop(reason string) { log.Debug("closing connection", "protocol", "amqp-1.0", "publisherId", p.Id, "reason", reason) - p.Connectionection.Close() + _ = p.Connectionection.Close() } diff --git a/pkg/common/common.go b/pkg/common/common.go index c6207bf..f35572c 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -31,24 +31,24 @@ func NewPublisher(protocol Protocol, cfg config.Config, id int) (Publisher, erro case AMQP: p := amqp10_client.NewPublisher(cfg, id) if p == nil { - return nil, fmt.Errorf("Failed to create an AMQP-1.0 publisher") + return nil, fmt.Errorf("failed to create an AMQP-1.0 publisher") } return p, nil case STOMP: p := stomp_client.NewPublisher(cfg, id) if p == nil { - return nil, fmt.Errorf("Failed to create a STOMP publisher") + return nil, fmt.Errorf("failed to create a STOMP publisher") } return p, nil case MQTT: p := mqtt_client.NewPublisher(cfg, id) if p == nil { - return nil, fmt.Errorf("Failed to create an MQTT publisher") + return nil, fmt.Errorf("failed to create an MQTT publisher") } return p, nil } - return nil, fmt.Errorf("Unknown protocol") + return nil, fmt.Errorf("unknown protocol") } func NewConsumer(protocol Protocol, cfg config.Config, id int) (Consumer, error) { @@ -56,22 +56,22 @@ func NewConsumer(protocol Protocol, cfg config.Config, id int) (Consumer, error) case AMQP: c := amqp10_client.NewConsumer(cfg, id) if c == nil { - return nil, fmt.Errorf("Failed to create an AMQP-1.0 consumer") + return nil, fmt.Errorf("failed to create an AMQP-1.0 consumer") } return c, nil case STOMP: c := stomp_client.NewConsumer(cfg, id) if c == nil { - return nil, fmt.Errorf("Failed to create an AMQP-1.0 consumer") + return nil, fmt.Errorf("failed to create an AMQP-1.0 consumer") } return c, nil case MQTT: c := mqtt_client.NewConsumer(cfg, id) if c == nil { - return nil, fmt.Errorf("Failed to create an AMQP-1.0 consumer") + return nil, fmt.Errorf("failed to create an AMQP-1.0 consumer") } return c, nil } - return nil, fmt.Errorf("Unknown protocol") + return nil, fmt.Errorf("unknown protocol") } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 10dcaa2..abf1fdd 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -124,7 +124,7 @@ func (m MetricsServer) PrintMetrics() { log.Error("Error getting metrics", "error", err) return } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() body, err := io.ReadAll(resp.Body) if err != nil {