From cca29ac4681c9ac7012449c5cabc985847365c66 Mon Sep 17 00:00:00 2001 From: CertoToStore Team Date: Wed, 11 Dec 2024 11:50:55 -0800 Subject: [PATCH] Wrap one of the errors. PiperOrigin-RevId: 705185321 --- sysinfo_windows.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sysinfo_windows.go b/sysinfo_windows.go index 6833906..b463ca7 100644 --- a/sysinfo_windows.go +++ b/sysinfo_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows // Copyright 2017 Google Inc. @@ -25,6 +26,11 @@ import ( "github.com/StackExchange/wmi" ) +var ( + // ErrNoNetworkAdapter is returned when no network adapter is detected. + ErrNoNetworkAdapter = errors.New("network adapter not detected") +) + // User will obtain the current user from the OS. func User() (string, error) { if u := os.Getenv("USERNAME"); u != "" { @@ -109,7 +115,7 @@ func NetInfo() ([]string, error) { } if len(netInfo) == 0 { - return nil, fmt.Errorf("network adapter not detected. got: %d want: >= 1", len(netInfo)) + return nil, fmt.Errorf("%w got: %d want: >= 1", ErrNoNetworkAdapter, len(netInfo)) } var macs []string