Re: [go-nuts] Unmarshal variable JSON structures

2022-12-26 Thread Marcin Romaszewicz
Here is an example of what I mean. https://go.dev/play/p/O6KIsxmSeaN This is why I wrote a code generator, it's tedious by hand :) On Mon, Dec 26, 2022 at 11:08 AM Marcin Romaszewicz wrote: > This is a very annoying problem, and one that we hit a lot in my project ( >

Re: [go-nuts] Runtime panic identification

2022-12-26 Thread Ian Lance Taylor
On Mon, Dec 26, 2022 at 10:56 AM Nikhilesh Susarla wrote: > > So the SigPanic() captures the "_SIGSEGV" and then panics the whole program > right? It depends on precisely what you mean by that. SIGSEGV is marked with the SigPanic flag in runtime/sigtab_linux_generic.go or whatever is the

Re: [go-nuts] Unmarshal variable JSON structures

2022-12-26 Thread Marcin Romaszewicz
This is a very annoying problem, and one that we hit a lot in my project ( https://github.com/deepmap/oapi-codegen), where we generate Go models from OpenAPI specs, and the OpenAPI "AnyOf" or "OneOf" schema does precisely this. You can partially unmarshal; store your "type" field in a typed

Re: [go-nuts] Runtime panic identification

2022-12-26 Thread Nikhilesh Susarla
So the SigPanic() captures the "_SIGSEGV" and then panics the whole program right? On Monday, 26 December 2022 at 23:49:12 UTC+5:30 Ian Lance Taylor wrote: > On Mon, Dec 26, 2022 at 9:49 AM Nikhilesh Susarla > wrote: > > > > https://play.golang.com/p/xpuit5lh9hh > > > > An array out of bounds

Re: [go-nuts] Runtime panic identification

2022-12-26 Thread Ian Lance Taylor
On Mon, Dec 26, 2022 at 9:49 AM Nikhilesh Susarla wrote: > > https://play.golang.com/p/xpuit5lh9hh > > An array out of bounds throws panic at runtime. > > How does the internal runtime know that we are accessing the memory which we > are not allocated? Interested in knowing more depth of the

[go-nuts] Unmarshal variable JSON structures

2022-12-26 Thread Andrew Burian
Hey all, wondering if there's an existing best practice for this so I'm not reinventing the wheel. It's frustratingly common to have APIs where the response JSON can be one of several distinct objects, and the indicator of which object has been returned is itself a property of the object. So you

[go-nuts] Runtime panic identification

2022-12-26 Thread Nikhilesh Susarla
Hello Gophers, https://play.golang.com/p/xpuit5lh9hh An array out of bounds throws panic at runtime. How does the internal runtime know that we are accessing the memory which we are not allocated? Interested in knowing more depth of the internals. This Link