Re: [go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Tim Casey
I solved this in some bizzaro way. Maybe what is needed is a json parser which is allowed to be multiple types. Or, another way to think about parsing which is easier on the type strictness, but still strongly typed. Like a duck typed struct of some sort. map[string]duck, where duck is allowed

Re: [go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread 'Jim Idle' via golang-nuts
You can also unmarshal in stages to Raw and then unmarshal the next piece based on what you have so far. I presume that you cannot change the format? On Fri, Sep 15, 2023 at 01:05 Tobias Klausmann wrote: > Hi! > > On Thu, 14 Sep 2023, Brian Candler wrote: > > Could you just unmarshal it to a

Re: [go-nuts] Re: Weird error when trying to fetch a module.

2023-09-14 Thread 'Jim Idle' via golang-nuts
It’s an absolute nightmare to publish modules from subdirectories. I gave up for ANTLR and created a new repo with the source code in the root directory. But the art is that you need to create a tag named with the subdirectory. I was able to make that work until we needed a v{n} tag. Which as far

[go-nuts] Re: Weird error when trying to fetch a module.

2023-09-14 Thread Lenny Kneller
Hi Bruno, This command works `github.com/flatgeobuf/flatgeobuf/src/go@master`. I wonder if `@master` is needed because the repo has no packages published? There's more info about pseudo-versions here -Lenny- On Thursday, September 14, 2023 at 5:59:39 PM

[go-nuts] Weird error when trying to fetch a module.

2023-09-14 Thread Bruno Albuquerque
It is likely that I am doing something stupid but as I am out of ideas, here goes nothing. I pushed an initial Go flatgeobuf implementation here: github.com/flatgeobuf/flatgeobuf/src/go This directory in the repository has a go.mod file with the following contents: module

Re: [go-nuts] JSON Compare

2023-09-14 Thread Petite Abeille
> On Sep 14, 2023, at 20:44, Sapna Jayavel wrote: > > Do we have any Go package to support this? # diff <(gron flare-2.json) <(gron flare-3.json) 15c15 < json.children[0].children[0].children[2].value = 6714; --- > json.children[0].children[0].children[2].value = 67144;

[go-nuts] JSON Compare

2023-09-14 Thread Sapna Jayavel
I am implementing a method find difference between two JSON objects and it has to drill down recursively. My usecase has very large nested JSON objects. Response should have the data that has changed between two JSON and position of the object. Do we have any Go package to support this? I

Re: [go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Tobias Klausmann
Hi! On Thu, 14 Sep 2023, Brian Candler wrote: > Could you just unmarshal it to a map[string]IntTSList, and then walk it and > build whatever structure you want? I will try and make that work tomorrow, thanks for the hint! > If you want to pick certain fixed fields into a struct and separate out

Re: [go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Brian Candler
Could you just unmarshal it to a map[string]IntTSList, and then walk it and build whatever structure you want? If you want to pick certain fixed fields into a struct and separate out the leftovers to be parsed as "subnet[X].Y", then see

Re: [go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Tobias Klausmann
Hi! On Thu, 14 Sep 2023, Peter Galbavy wrote: > You will need to create a custom type and unmarshal method. Plenty of > example if you search for "golang custom json unmarshal". > > As I've only had to implement it for a couple of simple types I can't offer > my own valid example. I am aware

[go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Peter Galbavy
You will need to create a custom type and unmarshal method. Plenty of example if you search for "golang custom json unmarshal". As I've only had to implement it for a couple of simple types I can't offer my own valid example. On Thursday, 14 September 2023 at 14:36:12 UTC+1 Tobias Klausmann

[go-nuts] Parsing difficult JSON

2023-09-14 Thread Tobias Klausmann
Hi! I am trying to write Prometheus exporter for stats queried fro the Kea DHCP server. Unfortunatly, the JSON is structured very badly if I want to use the base library JSON Unmarshal functionality: { "arguments": { "cumulative-assigned-addresses": [ [ 1, "2023-09-13

[go-nuts] Re: GO language best practice document

2023-09-14 Thread Jose Corral
Also, the Uber Go style guide has been a good resource for quite some time now: https://github.com/uber-go/guide/blob/master/style.md On Wednesday, September 13, 2023 at 2:18:11 PM UTC+2 jake...@gmail.com wrote: > In addition to the style guide, I have found >