本文整理匯總了Golang中runtime/debug.SetMaxStack函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetMaxStack函數的具體用法?Golang SetMaxStack怎麽用?Golang SetMaxStack使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SetMaxStack函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
示例2: StackOverflow
func StackOverflow() {
var f func() byte
f = func() byte {
var buf [64 << 10]byte
return buf[0] + f()
}
debug.SetMaxStack(1474560)
f()
}
示例3: testImportCycle
func testImportCycle(pkg string, t *testing.T) {
ctx := testContext(t)
debug.SetMaxStack(1 << 18)
_, err := ctx.ResolvePackage(pkg)
if strings.Index(err.Error(), "cycle detected") == -1 {
t.Errorf("ctx.ResolvePackage returned wrong error. Expected cycle detection, got: %v", err)
}
if err == nil {
t.Errorf("ctx.ResolvePackage should have returned an error for cycle, returned nil")
}
}
示例4: init
func init() {
// This test runs the risk of entering infinite recursion if it fails.
// Limit the stack size to 10 megs to creash early in that case instead of
// potentially taking down the box...
rdebug.SetMaxStack(10 * 1 << 20)
}
示例5: TestUNC
func TestUNC(t *testing.T) {
// Test that this doesn't go into an infinite recursion.
// See golang.org/issue/15879.
defer debug.SetMaxStack(debug.SetMaxStack(1e6))
filepath.Glob(`\\?\c:\*`)
}