func GoroutineProfile(p []StackRecord) (n int, ok bool) {
	gp := getg()

	isOK := func(gp1 *g) bool {
		// Checking isSystemGoroutine here makes GoroutineProfile
		// consistent with both NumGoroutine and Stack.
		return gp1 != gp && readgstatus(gp1) != _Gdead && !isSystemGoroutine(gp1)
	}

	stopTheWorld("profile")

	n = 1
	for _, gp1 := range allgs {
		if isOK(gp1) {
			n++
		}
	}

	if n <= len(p) {
		ok = true
		r := p

		// Save current goroutine.
		sp := getcallersp(unsafe.Pointer(&p))
		pc := getcallerpc(unsafe.Pointer(&p))
		systemstack(func() {
			saveg(pc, sp, gp, &r[0])
		})
		r = r[1:]

		// Save other goroutines.
		for _, gp1 := range allgs {
			if isOK(gp1) {
				if len(r) == 0 {
					// Should be impossible, but better to return a
					// truncated profile than to crash the entire process.
					break
				}
				saveg(^uintptr(0), ^uintptr(0), gp1, &r[0])
				r = r[1:]
			}
		}
	}

	startTheWorld()

	return n, ok
}
// GoroutineProfile returns n, the number of records in the active goroutine stack profile.
// If len(p) >= n, GoroutineProfile copies the profile into p and returns n, true.
// If len(p) < n, GoroutineProfile does not change p and returns n, false.
//
// Most clients should use the runtime/pprof package instead
// of calling GoroutineProfile directly.
GoroutineProfile returns n, the number of records in the active goroutine stack profile.
If len(p) >= n, GoroutineProfile copies the profile into p and returns n, true.
If len(p) < n, GoroutineProfile does not change p and returns n, false.

Most clients should use the runtime/pprof package instead
of calling GoroutineProfile directly.
// GoroutineProfile returns n the number of records in the active goroutine stack profile . // If len ( p ) > = n GoroutineProfile copies the profile into p and returns n true . // If len ( p ) < n GoroutineProfile does not change p and returns n false . // // Most clients should use the runtime / pprof package instead // of calling GoroutineProfile directly .
func GoroutineProfile(p []StackRecord) (n int, ok bool) {
	gp := getg()
	isOK := func(gp1 *g) bool {
		return gp1 != gp && readgstatus(gp1) != _Gdead && !isSystemGoroutine(gp1)
	}
	stopTheWorld("profile")
	n = 1
	for _, gp1 := range allgs {
		if isOK(gp1) {
			n++
		}
	}
	if n <= len(p) {
		ok = true
		r := p
		sp := getcallersp(unsafe.Pointer(&p))
		pc := getcallerpc(unsafe.Pointer(&p))
		systemstack(func() {
			saveg(pc, sp, gp, &r[0])
		})
		r = r[1:]
		for _, gp1 := range allgs {
			if isOK(gp1) {
				if len(r) == 0 {
					break
				}
				saveg(^uintptr(0), ^uintptr(0), gp1, &r[0])
				r = r[1:]
			}
		}
	}
	startTheWorld()
	return n, ok
}
func GoroutineProfile ( p [ ] StackRecord ) ( n int , ok bool ) { gp := getg ( ) isOK := func ( gp1 * g ) bool { return gp1 != gp && readgstatus ( gp1 ) != _Gdead && ! isSystemGoroutine ( gp1 ) } stopTheWorld ( " " ) n = 1 for _ , gp1 := range allgs { if isOK ( gp1 ) { n ++ } } if n <= len ( p ) { ok = true r := p sp := getcallersp ( unsafe . Pointer ( & p ) ) pc := getcallerpc ( unsafe . Pointer ( & p ) ) systemstack ( func ( ) { saveg ( pc , sp , gp , & r [ 0 ] ) } ) r = r [ 1 : ] for _ , gp1 := range allgs { if isOK ( gp1 ) { if len ( r ) == 0 { break } saveg ( ^ uintptr ( 0 ) , ^ uintptr ( 0 ) , gp1 , & r [ 0 ] ) r = r [ 1 : ] } } } startTheWorld ( ) return n , ok }
GoroutineProfile returns n, the number of records in the active goroutine stack profile.
GoroutineProfile returns n the number of records in the active goroutine stack profile .
// Checking isSystemGoroutine here makes GoroutineProfile // consistent with both NumGoroutine and Stack. // Save current goroutine. // Save other goroutines. // Should be impossible, but better to return a // truncated profile than to crash the entire process.