@@ -18,15 +18,15 @@ func DiffStrings(expected, actual string) (diff string, err error) {
18
18
var wg sync.WaitGroup
19
19
wg .Add (2 )
20
20
21
- var errs []error
21
+ errs := make ( []error , 2 )
22
22
23
23
// Format expected.
24
24
go func () {
25
25
defer wg .Done ()
26
26
e := new (strings.Builder )
27
27
err := htmlformat .Fragment (e , strings .NewReader (expected ))
28
28
if err != nil {
29
- errs = append ( errs , fmt .Errorf ("expected html formatting error: %w" , err ) )
29
+ errs [ 0 ] = fmt .Errorf ("expected html formatting error: %w" , err )
30
30
}
31
31
expected = e .String ()
32
32
}()
@@ -37,7 +37,7 @@ func DiffStrings(expected, actual string) (diff string, err error) {
37
37
a := new (strings.Builder )
38
38
err := htmlformat .Fragment (a , strings .NewReader (actual ))
39
39
if err != nil {
40
- errs = append ( errs , fmt .Errorf ("actual html formatting error: %w" , err ) )
40
+ errs [ 1 ] = fmt .Errorf ("actual html formatting error: %w" , err )
41
41
}
42
42
actual = a .String ()
43
43
}()
@@ -57,15 +57,15 @@ func DiffCtx(ctx context.Context, input templ.Component, expected string) (forma
57
57
var wg sync.WaitGroup
58
58
wg .Add (2 )
59
59
60
- var errs []error
60
+ errs := make ( []error , 3 )
61
61
62
62
// Format the expected value.
63
63
go func () {
64
64
defer wg .Done ()
65
65
e := new (strings.Builder )
66
66
err := htmlformat .Fragment (e , strings .NewReader (expected ))
67
67
if err != nil {
68
- errs = append ( errs , fmt .Errorf ("expected html formatting error: %w" , err ) )
68
+ errs [ 0 ] = fmt .Errorf ("expected html formatting error: %w" , err )
69
69
}
70
70
expected = e .String ()
71
71
}()
@@ -77,14 +77,14 @@ func DiffCtx(ctx context.Context, input templ.Component, expected string) (forma
77
77
defer wg .Done ()
78
78
err := htmlformat .Fragment (actual , r )
79
79
if err != nil {
80
- errs = append ( errs , fmt .Errorf ("actual html formatting error: %w" , err ) )
80
+ errs [ 1 ] = fmt .Errorf ("actual html formatting error: %w" , err )
81
81
}
82
82
}()
83
83
84
84
// Render the component.
85
85
err = input .Render (ctx , w )
86
86
if err != nil {
87
- errs = append ( errs , fmt .Errorf ("failed to render component: %w" , err ) )
87
+ errs [ 2 ] = fmt .Errorf ("failed to render component: %w" , err )
88
88
}
89
89
w .Close ()
90
90
0 commit comments