Skip to content

Commit 3b962e0

Browse files
committed
refactor: Address staticcheck suggestion, improve readability
1 parent 743f48a commit 3b962e0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spf2ip.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,14 @@ func (r *SPF2IPResolver) processDomain(ctx context.Context, domain string, depth
256256
}
257257

258258
func (r *SPF2IPResolver) lookupIPNetwork() string {
259-
if r.ipVersion == ipv4 {
259+
switch r.ipVersion {
260+
case ipv4:
260261
return "ip4"
261-
} else if r.ipVersion == ipv6 {
262+
case ipv6:
262263
return "ip6"
264+
default:
265+
return "ip" // Fallback, should not happen if ipVersion is correctly set
263266
}
264-
265-
return "ip" // Fallback, should not happen if ipVersion is correctly set
266267
}
267268

268269
func parseSPFMechanismTargetAndMask(defaultDomain, mechanismValue string) (targetHost, maskSuffix string) {
@@ -323,8 +324,7 @@ func (r *SPF2IPResolver) addIPOrCIDRToSet(value string, targetSet map[string]str
323324

324325
// Try CIDR first
325326
if ip, ipNet, err := net.ParseCIDR(value); err == nil {
326-
if (r.ipVersion == ipv4 && ip.To4() != nil) ||
327-
(r.ipVersion == ipv6 && ip.To4() == nil && ip.To16() != nil) {
327+
if (r.ipVersion == ipv4 && ip.To4() != nil) || (r.ipVersion == ipv6 && ip.To4() == nil && ip.To16() != nil) {
328328
targetSet[ipNet.String()] = struct{}{}
329329
return nil
330330
}

0 commit comments

Comments
 (0)