From 2996a161cda347ab62806c33b9ec221e46c3aa5d Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 16 Jul 2025 17:27:27 +0700 Subject: [PATCH] Fix tautological condition in findWorkingInterface - Add explicit foundDefaultRoute boolean variable to track default route discovery - Initialize foundDefaultRoute to false and set to true only in success case - Replace tautological condition `err == nil` with meaningful `foundDefaultRoute` check - Fixes "tautological condition: nil == nil" linter error The error occurred because err was being reused from net.Interfaces() call, making the condition always true. Now we explicitly track whether a default route was successfully found. --- cmd/cli/prog.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/cli/prog.go b/cmd/cli/prog.go index 40e723f..5d3c101 100644 --- a/cmd/cli/prog.go +++ b/cmd/cli/prog.go @@ -1042,12 +1042,14 @@ func (p *prog) findWorkingInterface() string { } // Get default route interface + foundDefaultRoute := false defaultRoute, err := netmon.DefaultRoute() if err != nil { p.Debug(). Err(err). Msg("failed to get default route") } else { + foundDefaultRoute = true p.Debug(). Str("default_route_iface", defaultRoute.InterfaceName). Msg("found default route") @@ -1084,7 +1086,7 @@ func (p *prog) findWorkingInterface() string { } // Found working physical interface - if err == nil && defaultRoute.InterfaceName == iface.Name { + if foundDefaultRoute && defaultRoute.InterfaceName == iface.Name { // Found interface with default route - use it immediately p.Info(). Str("old_iface", currentIface).