From fac8202c3ffdddf5d2b35a2c3620c1eb56018b9b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 6 Jan 2016 21:16:01 -0500 Subject: runtime: make NumGoroutine and Stack agree not to include system goroutines [Repeat of CL 18343 with build fixes.] Before, NumGoroutine counted system goroutines and Stack (usually) didn't show them, which was inconsistent and confusing. To resolve which way they should be consistent, it seems like package main import "runtime" func main() { println(runtime.NumGoroutine()) } should print 1 regardless of internal runtime details. Make it so. Fixes #11706. Change-Id: If26749fec06aa0ff84311f7941b88d140552e81d Reviewed-on: https://go-review.googlesource.com/18432 Reviewed-by: Austin Clements Run-TryBot: Russ Cox --- src/runtime/testdata/testprog/misc.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/runtime/testdata/testprog/misc.go (limited to 'src/runtime/testdata') diff --git a/src/runtime/testdata/testprog/misc.go b/src/runtime/testdata/testprog/misc.go new file mode 100644 index 0000000000..237680fc87 --- /dev/null +++ b/src/runtime/testdata/testprog/misc.go @@ -0,0 +1,15 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "runtime" + +func init() { + register("NumGoroutine", NumGoroutine) +} + +func NumGoroutine() { + println(runtime.NumGoroutine()) +} -- cgit v1.3