2018-05-31 09:51:00 -06:00
|
|
|
// run
|
2011-06-13 06:50:51 -06:00
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
2011-06-13 06:50:51 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2012-02-18 20:28:53 -07:00
|
|
|
// Test that println can be the target of a go statement.
|
|
|
|
|
2011-06-13 06:50:51 -06:00
|
|
|
package main
|
|
|
|
|
2016-04-06 11:42:14 -06:00
|
|
|
import (
|
2019-10-10 13:23:03 -06:00
|
|
|
"log"
|
2016-04-06 11:42:14 -06:00
|
|
|
"runtime"
|
|
|
|
"time"
|
|
|
|
)
|
2011-06-13 06:50:51 -06:00
|
|
|
|
|
|
|
func main() {
|
2019-10-10 13:23:03 -06:00
|
|
|
numg0 := runtime.NumGoroutine()
|
|
|
|
deadline := time.Now().Add(10 * time.Second)
|
2011-06-13 06:50:51 -06:00
|
|
|
go println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255))
|
2019-10-10 13:23:03 -06:00
|
|
|
for {
|
|
|
|
numg := runtime.NumGoroutine()
|
|
|
|
if numg > numg0 {
|
|
|
|
if time.Now().After(deadline) {
|
|
|
|
log.Fatalf("%d goroutines > initial %d after deadline", numg, numg0)
|
|
|
|
}
|
|
|
|
runtime.Gosched()
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
break
|
2016-04-06 11:42:14 -06:00
|
|
|
}
|
2011-06-13 06:50:51 -06:00
|
|
|
}
|