mirror of
https://github.com/TwiN/gatus.git
synced 2026-02-14 18:42:27 +00:00
refactor: Simplify and modernize loops (#1522)
* refactor: Simplify loops * refactor: Modernize loops using range over int --------- Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package endpoint
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -66,11 +67,7 @@ type Result struct {
|
||||
// AddError adds an error to the result's list of errors.
|
||||
// It also ensures that there are no duplicates.
|
||||
func (r *Result) AddError(error string) {
|
||||
for _, resultError := range r.Errors {
|
||||
if resultError == error {
|
||||
// If the error already exists, don't add it
|
||||
return
|
||||
}
|
||||
if !slices.Contains(r.Errors, error) {
|
||||
r.Errors = append(r.Errors, error+"")
|
||||
}
|
||||
r.Errors = append(r.Errors, error+"")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user