From 36bf6f98cf683b2482f406ce493a58bb280d9c00 Mon Sep 17 00:00:00 2001 From: "Wilke, Louis" Date: Mon, 15 Jan 2024 19:22:03 +0100 Subject: [PATCH] removed usage of errors.Join --- aht20/aht20.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aht20/aht20.go b/aht20/aht20.go index 00accbc..ddb00c4 100644 --- a/aht20/aht20.go +++ b/aht20/aht20.go @@ -5,7 +5,6 @@ package aht20 import ( - "errors" "fmt" "periph.io/x/conn/v3/i2c" "periph.io/x/conn/v3/physic" @@ -65,16 +64,17 @@ func NewI2C(b i2c.Bus, opts *Opts) (*Dev, error) { if opts == nil { opts = &DefaultOpts } - if opts.MeasurementWaitInterval <= 0 { - opts.MeasurementWaitInterval = 10 * time.Millisecond + d := &Dev{d: &i2c.Dev{Bus: b, Addr: deviceAddress}, opts: *opts} + + if d.opts.MeasurementWaitInterval <= 0 { + d.opts.MeasurementWaitInterval = 10 * time.Millisecond } - d := &Dev{d: &i2c.Dev{Bus: b, Addr: deviceAddress}, opts: *opts} if err, initialized := d.isInitialized(); err != nil { - return nil, errors.Join(fmt.Errorf("could read sensor status"), err) + return nil, fmt.Errorf("%w; could read sensor status", err) } else if !initialized { if err := d.initialize(); err != nil { - return nil, errors.Join(fmt.Errorf("could not calibrate sensor"), err) + return nil, fmt.Errorf("%w; could not calibrate sensor", err) } } return d, nil