From time to time, newcomers to Go stumble upon an interesting language property related to the stack size available to the goroutine. This usually happens because the programmer inadvertently creates an infinite recursion. To illustrate this, consider the following (slightly contrived) example.
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.