Chore: Refactor code with go fix

Done with `go fix ./...` using go 1.26.0.
This commit is contained in:
Ville Skyttä
2026-03-03 00:26:52 +02:00
committed by Ralph Slooten
parent 5e9c522402
commit 2afc52c6fe
22 changed files with 72 additions and 82 deletions

View File

@@ -42,19 +42,19 @@ type CanIEmail struct {
// JSONResult struct for CanIEmail Data
type JSONResult struct {
Slug string `json:"slug"`
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
Category string `json:"category"`
Tags []string `json:"tags"`
Keywords string `json:"keywords"`
LastTestDate string `json:"last_test_date"`
TestURL string `json:"test_url"`
TestResultsURL string `json:"test_results_url"`
Stats map[string]interface{} `json:"stats"`
Notes string `json:"notes"`
NotesByNumber map[string]string `json:"notes_by_num"`
Slug string `json:"slug"`
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
Category string `json:"category"`
Tags []string `json:"tags"`
Keywords string `json:"keywords"`
LastTestDate string `json:"last_test_date"`
TestURL string `json:"test_url"`
TestResultsURL string `json:"test_results_url"`
Stats map[string]any `json:"stats"`
Notes string `json:"notes"`
NotesByNumber map[string]string `json:"notes_by_num"`
}
// Load the JSON data

View File

@@ -72,7 +72,7 @@ func TestInlineStyleDetection(t *testing.T) {
}
}
func assertEqual(t *testing.T, a interface{}, b interface{}, message string) {
func assertEqual(t *testing.T, a any, b any, message string) {
if a == b {
return
}

View File

@@ -141,11 +141,11 @@ func (c CanIEmail) getTest(k string) (Warning, error) {
continue
}
for platform, clients := range stats.(map[string]interface{}) {
for platform, clients := range stats.(map[string]any) {
if len(LimitPlatforms) != 0 && !tools.InArray(platform, LimitPlatforms) {
continue
}
for version, support := range clients.(map[string]interface{}) {
for version, support := range clients.(map[string]any) {
s := Result{}
s.Name = fmt.Sprintf("%s %s (%s)", c.NiceNames.Family[family], c.NiceNames.Platform[platform], version)
s.Family = family

View File

@@ -1,7 +1,7 @@
package htmlcheck
import (
"sort"
"slices"
"github.com/axllent/mailpit/internal/tools"
)
@@ -18,7 +18,7 @@ func Platforms() (map[string][]string, error) {
for _, t := range cie.Data {
for family, stats := range t.Stats {
niceFamily := cie.NiceNames.Family[family]
for platform := range stats.(map[string]interface{}) {
for platform := range stats.(map[string]any) {
c, found := data[platform]
if !found {
data[platform] = []string{}
@@ -32,9 +32,7 @@ func Platforms() (map[string][]string, error) {
}
for group, clients := range data {
sort.Slice(clients, func(i, j int) bool {
return clients[i] < clients[j]
})
slices.Sort(clients)
data[group] = clients
}