Closed W-Lawless closed 1 year ago
And without opening another issue; I think it may benefit the library to implement Go generics in places such as
type Edge struct {
ID [uint64]
Relation [string]
Source *[Node]
Destination *[Node]
Properties map[string]interface{} <----
}
I primarily work in Swift, so during the course of exploring this today I actually discovered that an interface is essentially a swift protocol
The way it was being used here threw me off as admittedly I'm learning Go as I go (lol) and the way an empty interface
I've typically seen used is like the 'we don't have generics so we make due' of Go, so I didn't even really understand what it was at first.
That being said, as generics types are included now, maybe you can rework some areas of the lib to use them? Go seems like they were begrudgingly reluctant to offer them at all.
Either way, perhaps I'm trying to force a Swift/OO paradigm onto Go with my above approach; perhaps there's another solution to what I'm attempting here that doesn't involve generic types at all and instead follows a more true-to-intent use of interface
and functional paradigm?
Turns out my code works fine 😎
The only problem is that I had my "name" label passing an integer value for my NavButton
-- changing my Label
value to "count" fixed everything.
Feel free to add my contribution to the documentation as example code! It's pretty slick I gotta say
Hi,
I might not have properly understood the paradigm of the library, but I was looking to generalize the creation of nodes and edges through the use of builder/factory methods. So far as I can tell, there are no errors in my Go implementation, and the data does
RETURN
properly when I examine it through RedisInsight. However, the visualizer is broken. I can only view my data as raw text; which really defeats the purpose of loading everything into a graph in the first place.My implementation isn't too long, but pulling off the various hat-tricks with generics and getting the types to play together did take the majority of the day.
Relevant types:
Node factories:
Edge factories:
The caller function:
Result One:
Result Two:
Result Two is curious, as RedisInsight returns this data for the same query:
I can shelf this for now and I suppose attempt the same intent of what I'd like to do here by creating factories that parse/output Cypher statements, but that doesn't really seem to be in the spirit of the library.