From 3c0648f9215a7316550a3ca26f811fef31af1b79 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 5 Mar 2026 11:39:11 -0800 Subject: [PATCH] Apply go fix modernizations --- validate.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/validate.go b/validate.go index bb5e793..18e0d96 100644 --- a/validate.go +++ b/validate.go @@ -25,11 +25,11 @@ func (r *ValidationResult) addField(name, value string) { r.Fields = append(r.Fields, FieldInfo{Name: name, Value: value}) } -func (r *ValidationResult) addError(format string, args ...interface{}) { +func (r *ValidationResult) addError(format string, args ...any) { r.Errors = append(r.Errors, fmt.Sprintf(format, args...)) } -func (r *ValidationResult) addWarning(format string, args ...interface{}) { +func (r *ValidationResult) addWarning(format string, args ...any) { r.Warnings = append(r.Warnings, fmt.Sprintf(format, args...)) } @@ -339,21 +339,21 @@ func validateArtPollReply(data []byte, src *net.UDPAddr, result *ValidationResul // Field 20: PortTypes[4] result.addField("PortTypes", fmt.Sprintf("[0x%02X, 0x%02X, 0x%02X, 0x%02X]", data[174], data[175], data[176], data[177])) - for i := 0; i < 4; i++ { + for i := range 4 { validatePortType(data[174+i], i, result) } // Field 21: GoodInput[4] result.addField("GoodInput", fmt.Sprintf("[0x%02X, 0x%02X, 0x%02X, 0x%02X]", data[178], data[179], data[180], data[181])) - for i := 0; i < 4; i++ { + for i := range 4 { validateGoodInput(data[178+i], i, result) } // Field 22: GoodOutputA[4] result.addField("GoodOutputA", fmt.Sprintf("[0x%02X, 0x%02X, 0x%02X, 0x%02X]", data[182], data[183], data[184], data[185])) - for i := 0; i < 4; i++ { + for i := range 4 { validateGoodOutputA(data[182+i], i, result) } @@ -413,7 +413,7 @@ func validateArtPollReply(data []byte, src *net.UDPAddr, result *ValidationResul result.addField("SwRemote", fmt.Sprintf("0x%02X", swRemote)) // Fields 28-30: Spare (should be zero) - for i := 0; i < 3; i++ { + for i := range 3 { if data[197+i] != 0 { result.addWarning("Spare byte at offset %d is 0x%02X (should be 0)", 197+i, data[197+i]) } @@ -468,7 +468,7 @@ func validateArtPollReply(data []byte, src *net.UDPAddr, result *ValidationResul // Field 41: GoodOutputB[4] result.addField("GoodOutputB", fmt.Sprintf("[0x%02X, 0x%02X, 0x%02X, 0x%02X]", data[213], data[214], data[215], data[216])) - for i := 0; i < 4; i++ { + for i := range 4 { validateGoodOutputB(data[213+i], i, result) } } @@ -804,11 +804,11 @@ func validateNodeReport(report string, result *ValidationResult) { func validateBackgroundQueuePolicy(policy byte, result *ValidationResult) { policies := map[byte]string{ - 0: "Collect using STATUS_NONE", - 1: "Collect using STATUS_ADVISORY", - 2: "Collect using STATUS_WARNING", - 3: "Collect using STATUS_ERROR", - 4: "Collection disabled", + 0: "Collect using STATUS_NONE", + 1: "Collect using STATUS_ADVISORY", + 2: "Collect using STATUS_WARNING", + 3: "Collect using STATUS_ERROR", + 4: "Collection disabled", } if name, ok := policies[policy]; ok {