De temps en temps, les nouveaux arrivants à Go tombent sur une propriété de langage intéressante liée à la taille de pile disponible pour un goroutine. Cela se produit généralement parce que le programmeur crée par inadvertance une récursivité infinie. Pour illustrer cela, considérons l'exemple suivant (légèrement artificiel).
package main import "fmt" type S struct { a, b int } // String implements the fmt.Stringer interface func (s *S) String() string { return fmt.Sprintf("%s", s) // Sprintf will call s.String() } func main() { s := &S{a: 1, b: 2} fmt.Println(s) }
, , , . , , Go?
— ; ( 1–8 POSIX), . 4096 ( Go 2048 — . ), - .
, (5l, 6l, 8l) "" [1], , . , , , runtime morestack, [2], (caller), , . , , , .
Go , , , .
, , , Go , .
, , . , .
, Go, , , , , , , .
Go 1.1 32-, 64- , , .. , 128 [3] .
. : (2013 ) Go , 1 GB 64 250 MB 32.
- , , , .
- «» , 4096 , runtime⋅morestack , , .
- 64- Windows 32 - Go 1.1.