But I'm using other variable not the one I'm unmarshaling to: var ts Result err := json.Unmarshal(b, &ts)
On Friday, September 29, 2017 at 2:10:25 AM UTC+3, Steven Hartland wrote: > > You created an infinite recursion by calling Unmarshal on the same type > your unmarshalling, hence the stack overflow error. > > On 28/09/2017 23:59, Yaroslav Molochko wrote: > > Here is the code which runs: > > https://play.golang.org/p/ds3KZspFvE > > If you press play, it will work fine and gives an expected output, > > as soon as you uncomment this part: > /* > func (u *Result) UnmarshalJSON(b []byte) error { > var ts Result > err := json.Unmarshal(b, &ts) > if err != nil { > fmt.Println(err) > } > return nil > } > */ > > which basically does nothing, you will get: > https://play.golang.org/p/Y9NTzpwyQy > > > runtime: goroutine stack exceeds 250000000-byte limit > fatal error: stack overflow > > runtime stack: > runtime.throw(0x122c5a, 0xe) > /usr/local/go/src/runtime/panic.go:605 +0x100 > runtime.newstack(0x0, 0x0) > /usr/local/go/src/runtime/stack.go:1050 +0x960 > runtime.morestack() > /usr/local/go/src/runtime/asm_amd64p32.s:378 +0xa0 > > > Anyone knows how to solve it? > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.