refactor(gofix): modernize

This commit is contained in:
Julien Neuhart
2026-02-20 21:21:19 +01:00
parent aea7c5952a
commit 2baa59cb3a
29 changed files with 131 additions and 149 deletions

View File

@@ -5,11 +5,11 @@ import (
"reflect"
)
func compareJson(expected, actual interface{}) error {
func compareJson(expected, actual any) error {
// Handle maps (JSON objects).
expectedMap, ok := expected.(map[string]interface{})
expectedMap, ok := expected.(map[string]any)
if ok {
actualMap, ok := actual.(map[string]interface{})
actualMap, ok := actual.(map[string]any)
if !ok {
return fmt.Errorf("expected an object, but actual is: %T", actual)
}
@@ -31,9 +31,9 @@ func compareJson(expected, actual interface{}) error {
}
// Handle slices (JSON arrays).
expectedSlice, ok := expected.([]interface{})
expectedSlice, ok := expected.([]any)
if ok {
actualSlice, ok := actual.([]interface{})
actualSlice, ok := actual.([]any)
if !ok {
return fmt.Errorf("expected an array, but actual is: %T", actual)
}

View File

@@ -22,7 +22,7 @@ var (
type noopLogger struct{}
func (n *noopLogger) Printf(format string, v ...interface{}) {
func (n *noopLogger) Printf(format string, v ...any) {
// NOOP
}

View File

@@ -327,11 +327,8 @@ func (s *scenario) iMakeConcurrentRequestsToGotenberg(ctx context.Context, count
s.concurrentResps = make([]*httptest.ResponseRecorder, 0, count)
errs := make([]error, 0)
for i := 0; i < count; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for range count {
wg.Go(func() {
resp, reqErr := doFormDataRequest(method, fmt.Sprintf("%s%s", base, endpoint), fields, files, headers)
if reqErr != nil {
mu.Lock()
@@ -387,7 +384,7 @@ func (s *scenario) iMakeConcurrentRequestsToGotenberg(ctx context.Context, count
mu.Lock()
s.concurrentResps = append(s.concurrentResps, rec)
mu.Unlock()
}()
})
}
wg.Wait()
@@ -495,7 +492,7 @@ func (s *scenario) theGotenbergContainerShouldLogTheFollowingEntries(ctx context
}
var err error
for i := 0; i < 3; i++ {
for range 3 {
err = check()
if err != nil && !invert {
// We have to retry as not all logs may have been produced.
@@ -618,7 +615,7 @@ func (s *scenario) theBodyShouldMatchJSON(kind string, expectedDoc *godog.DocStr
body = s.server.bodyCopy
}
var expected, actual interface{}
var expected, actual any
content := strings.ReplaceAll(expectedDoc.Content, "{version}", GotenbergVersion)
err := json.Unmarshal([]byte(content), &expected)