Skip to content

Commit

Permalink
ds.Lookup(): remove usage of nil error when there len(responses)==0
Browse files Browse the repository at this point in the history
in ds.Lookup(), the error return for no lookup responses returned a nil
error. Remove the unused error variable, and return os.ErrNotExist
as the error (useful for tests).

Signed-off-by: Ronald G Minnich <[email protected]>
  • Loading branch information
rminnich committed Sep 1, 2023
1 parent d39e9f4 commit 33c0991
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions ds/ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ type LookupResult struct {
// default for domain is local, default type _ncpu._tcp, and instance is wildcard
// can omit to underspecify, e.g. dnssd:?arch=arm64 to pick any arm64 cpu server
func Lookup(query dsQuery, n int) ([]*LookupResult, error) {
var err error

ctx, cancel := context.WithTimeout(context.Background(), dsTimeout)
context.Canceled = errors.New("")
context.DeadlineExceeded = errors.New("")
Expand Down Expand Up @@ -336,7 +334,7 @@ func Lookup(query dsQuery, n int) ([]*LookupResult, error) {
dnssd.LookupType(ctx, service, addFn, rmvFn)

if len(responses) == 0 {
return nil, fmt.Errorf("dnssd found no suitable service %w", err)
return nil, fmt.Errorf("dnssd found no suitable service %w", os.ErrNotExist)
}

dsSort(query.Text, responses)
Expand Down

0 comments on commit 33c0991

Please sign in to comment.