Source file src/runtime/testdata/testprog/typelinksrace.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"fmt"
     9  	"reflect"
    10  )
    11  
    12  
    13  func init() {
    14  	register("TypelinksRace", TypelinksRace)
    15  }
    16  
    17  const N = 2
    18  
    19  type T int
    20  
    21  // just needs some exotic type that the compiler doesn't build its pointer type
    22  var t = reflect.TypeOf([5]T{})
    23  
    24  var ch = make(chan int, N)
    25  
    26  func TypelinksRace() {
    27  	for range N {
    28  		go func() {
    29  			_ = reflect.PointerTo(t)
    30  			ch <- 1
    31  		}()
    32  	}
    33  	for range N {
    34  		<-ch
    35  	}
    36  	fmt.Println("OK")
    37  }
    38  

View as plain text