awalterschulze / gographviz

Parses the Graphviz DOT language in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Escape API doesn't properly escape nodes with file names

kevin-hanselman opened this issue · comments

A minimal example:

package main

import (
        "fmt"
        gv "github.com/awalterschulze/gographviz"
)

func main() {
        graph := gv.NewEscape()
        graph.SetName("G")
        graph.AddNode("G", "a.txt", nil)
        graph.AddNode("G", "b.txt", nil)
        fmt.Println(graph.String())
}

Output:

$ go run main.go
graph G {
        a.txt;
        b.txt;

}

$ go run main.go | dot -Tpng -o out.png
Error: <stdin>: syntax error in line 2 near '.'

Great catch, thank you for reporting.
Would you like to make a pull request to fix?

Turns out go mod was using the latest tagged release (2.0.1 from April) instead of master; this issue is not present on master. (I'm fairly new to Go and Go modules, so I didn't realize this was the default behavior of go mod.)

It might be a good idea to cut a new release to prevent this sort of confusion?

Great idea and thanks for pointing it out.
I have made a new release v2.0.2
This includes the escaping of the dot.
I hope that helps.