I want to run a dot script that outputs to an image.
How do I call it from Golang?
package main
import (
"fmt"
"os/exec"
)
func main() {
path, err := exec.LookPath("dot")
cmd := exec.Command(path, "-Tpng", "/Users/arafat/Desktop/dev/go/src/github.com/Arafatk/dataviz/DotExamples/arraylist.dot", ">", "/Users/arafat/Desktop/dev/go/src/github.com/Arafatk/dataviz/hello.png")
err = cmd.Run()
fmt.Println(path)
if err != nil {
println(err.Error())
return
}
}
This is my code which gives exit code 3.
@zerkms
Sorry, I can do that I am just confused because this code does not give any output except nil.
path, _ := exec.LookPath("dot")
cmd := exec.Command(path, "-Tpng", "/Users/arafat/Desktop/dev/go/src/github.com/Arafatk/dataviz/DotExamples/arraylist.dot")
out := cmd.Run()
fmt.Println(out)
But this command line function works
dot -Tpng /Users/arafat/Desktop/dev/go/src/github.com/Arafatk/dataviz/DotExamples/arraylist.dot
Can you tell me how to actually use the function above in Golang?