@@ -29,7 +29,6 @@ func TestPrintGolden(t *testing.T) {
2929 t .Fatal (err )
3030 }
3131 for _ , out := range outs {
32- out := out
3332 name := strings .TrimSuffix (filepath .Base (out ), ".golden" )
3433 t .Run (name , func (t * testing.T ) {
3534 t .Parallel ()
@@ -149,7 +148,6 @@ func TestPrintParse(t *testing.T) {
149148 t .Fatal (err )
150149 }
151150 for _ , out := range outs {
152- out := out
153151 name := filepath .Base (out )
154152 if ! strings .HasSuffix (out , ".in" ) && ! strings .HasSuffix (out , ".golden" ) {
155153 continue
@@ -216,8 +214,8 @@ func TestPrintParse(t *testing.T) {
216214 ndata = ndata2
217215 }
218216
219- if strings .HasSuffix (out , ".in" ) {
220- golden , err := os .ReadFile (strings . TrimSuffix ( out , ".in" ) + ".golden" )
217+ if before , ok := strings .CutSuffix (out , ".in" ); ok {
218+ golden , err := os .ReadFile (before + ".golden" )
221219 if err != nil {
222220 t .Fatal (err )
223221 }
@@ -239,14 +237,14 @@ type eqchecker struct {
239237
240238// errorf returns an error described by the printf-style format and arguments,
241239// inserting the current file position before the error text.
242- func (eq * eqchecker ) errorf (format string , args ... interface {} ) error {
240+ func (eq * eqchecker ) errorf (format string , args ... any ) error {
243241 return fmt .Errorf ("%s:%d: %s" , eq .file , eq .pos .Line ,
244242 fmt .Sprintf (format , args ... ))
245243}
246244
247245// check checks that v and w represent the same parse tree.
248246// If not, it returns an error describing the first difference.
249- func (eq * eqchecker ) check (v , w interface {} ) error {
247+ func (eq * eqchecker ) check (v , w any ) error {
250248 return eq .checkValue (reflect .ValueOf (v ), reflect .ValueOf (w ))
251249}
252250
@@ -322,7 +320,7 @@ func (eq *eqchecker) checkValue(v, w reflect.Value) error {
322320 // Fields in struct must match.
323321 t := v .Type ()
324322 n := t .NumField ()
325- for i := 0 ; i < n ; i ++ {
323+ for i := range n {
326324 tf := t .Field (i )
327325 switch {
328326 default :
@@ -335,7 +333,7 @@ func (eq *eqchecker) checkValue(v, w reflect.Value) error {
335333 }
336334 }
337335
338- case reflect .Ptr , reflect .Interface :
336+ case reflect .Pointer , reflect .Interface :
339337 if v .IsNil () != w .IsNil () {
340338 if v .IsNil () {
341339 return eq .errorf ("unexpected %s" , w .Elem ().Type ())
0 commit comments