本文整理汇总了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:\*`)
}