The best method I've found is to wrap the input reader in something that keeps track of lines. You can then type-assert the errors to one of the exported error types in the json package to get the offset the error occured and translate it into line numbers using your wrapper. I have a package for such a wrapper here: https://pkg.go.dev/gonih.org/lines though it's not particularly well tested.
On Tue, Feb 7, 2023 at 12:22 AM dave <david.c...@philabs.xyz> wrote: > I'm getting the error > > panic: json: cannot unmarshal string into Go value of type > map[string]*json.RawMessage but it does not tell me which line or section > of my json is causing the issue. How can I see this? > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/5873fef8-9787-4a5a-b543-61f6f313def6n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/5873fef8-9787-4a5a-b543-61f6f313def6n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfFAHh1PD1g2npXN_%2BvrpkLjfYcYSkjZrSsBpM6p42npuA%40mail.gmail.com.