From 0593c8dc402f0c25804d68cab94cafb50d0bd93c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96rjan=20Fors?= Date: Wed, 28 Aug 2024 14:55:13 +0200 Subject: [PATCH] feat: add distinct usb error --- pkg/atecc/hal_hid.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/atecc/hal_hid.go b/pkg/atecc/hal_hid.go index 02221f9..9669e2a 100644 --- a/pkg/atecc/hal_hid.go +++ b/pkg/atecc/hal_hid.go @@ -9,10 +9,16 @@ import ( "github.com/karalabe/usb" ) +// ErrUSBNotSupported is returned when the USB support is missing. +// +// When building, CGO is required for USB support. If CGO is not enabled, the +// HID interface will not be available. +var ErrUSBNotSupported = errors.New("atecc: usb support is missing") + // NewHIDDev returns an object that communicates over HID. func NewHIDDev(ctx context.Context, cfg IfaceConfig) (*Dev, io.Closer, error) { if !usb.Supported() { - return nil, nil, errors.New("atecc: hid is not supported") + return nil, nil, ErrUSBNotSupported } deviceInfos, err := usb.EnumerateHid(cfg.HID.VendorID, cfg.HID.ProductID)