memviz
memviz copied to clipboard
Document compatible graphviz versions
I'm getting syntax errors when trying to run the output through dot, for example:
axelw@axelw-1 ~/src/github.com/bradleyjkemp/memmap/.snapshots$ dot TestFib
Error: TestFib: syntax error in line 1 near '('
I assume I don't have a sufficiently recent version of graphviz installed, this is dot -version
:
dot - graphviz version 2.38.0 (20140413.2041)
libdir = "/usr/lib/graphviz"
Activated plugin library: libgvplugin_dot_layout.so.6
Using layout: dot:dot_layout
Activated plugin library: libgvplugin_core.so.6
Using render: dot:core
Using device: dot:dot:core
The plugin configuration file:
/usr/lib/graphviz/config6a
was successfully loaded.
render : cairo dot fig gd map pic pov ps svg tk vml vrml xdot
layout : circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
textlayout : textlayout
device : canon cmap cmapx cmapx_np dot eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg pdf pic plain plain-ext png pov ps ps2 svg svgz tk vml vmlz vrml wbmp x11 xdot xdot1.2 xdot1.4 xlib
loadimage : (lib) eps gd gd2 gif jpe jpeg jpg png ps svg xbm
Ah, no that's just an artifact of the snapshot testing. If you open .snapshots/TestFib you'll see that the output from memmap is wrapped in "bytes.Buffer(****)" as that's how I captured the output. If you run TestFib directly then it'll print the output to stdout as well and that should be valid.
Okay, you are correct, I misattributed the problem; I ran into issues and tried to reproduce them on known-good output but didn't know it's not known-good :)
There still is an issue, though, but it actually lies with memmap
then:
mero@hix /tmp/foo$ cat main.go 130
package main
import (
"os"
"github.com/bradleyjkemp/memmap"
)
type Foo struct {
Bar string
}
func main() {
f := Foo{`"Hello World"`}
memmap.Map(os.Stdout, &f)
}
mero@hix /tmp/foo$ go run main.go
digraph structs {
node [shape=Mrecord];
1 [label="<name> Foo |{<f0> Bar | \""Hello World"\"} "];
}
mero@hix /tmp/foo$ go run main.go | dot
Error: <stdin>: syntax error in line 3 near 'World'
string escaping seems broken, I sent a PR about that: #19
I think it would still be useful to document more the end-to-end process and the necessary version of graphviz, but at least my immediate problem is solved :)
Ah nice catch, yeah I hadn't considered strings with quotes in them.
And agreed, documentation definitely needs a lot of work...