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

     1  // Copyright 2017 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  	"runtime"
     9  	"sync"
    10  )
    11  
    12  func init() {
    13  	register("PanicRace", PanicRace)
    14  }
    15  
    16  func PanicRace() {
    17  	var wg sync.WaitGroup
    18  	wg.Add(1)
    19  	go func() {
    20  		defer func() {
    21  			wg.Done()
    22  			runtime.Gosched()
    23  		}()
    24  		panic("crash")
    25  	}()
    26  	wg.Wait()
    27  }
    28  

View as plain text