go-ds-crdt
go-ds-crdt copied to clipboard
PrintDAG should take either a PrinterFunc or a buffer
The PrintDAG should take either a PrinterFunc(line string) as an argument, or an io.Writer so you can control what the function prints to. I noticed the comments on the PrintDAG function even mention a printerFunc.
Might be a small niche use-case but as an experimental use of the crdt Datastore I've made an HTTP server that takes a go-datastore interface and exposes a basic API, it would be nice to be able to print the DAG and return it over the API. At the moment my only options are using my own fork that implements one of these two options, or some janky stdout copy/buffer stuff (don't want to do).
Thoughts?
Alternatively the function could just return a string, however, then it would probably need a name change to something like DAGToString()
.
That function is not really used (I used it mostly for debugging at the beginning). It doesn't even work very well (printing a multi-branched DAG is pretty horrible).
I'm happy changing it to whatever fits your needs. Would you like to make a PR?