aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modcmd/graph.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2018-08-21 02:43:45 +0000
committerRuss Cox <rsc@golang.org>2018-08-21 02:44:04 +0000
commita0212aa6273395c400092383bbdebc251ebacd2d (patch)
treec7fb1934e1b0269a5748f6da50047984d26711de /src/cmd/go/internal/modcmd/graph.go
parent27ed675b4bbb63b5b5d84a21be583ef6147a2084 (diff)
downloadgo-a0212aa6273395c400092383bbdebc251ebacd2d.tar.gz
go-a0212aa6273395c400092383bbdebc251ebacd2d.zip
cmd/go: revert "add graphviz output to graph command"
This reverts commit 723479bc30f998f29ecbba7caea118ac4e2c9afd. Reason for revert: other tools should convert the graph output to graphviz. Change-Id: Ide5b8f0b061aaff74bb6ba4c2a8f8768d1fbc05a Reviewed-on: https://go-review.googlesource.com/130295 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modcmd/graph.go')
-rw-r--r--src/cmd/go/internal/modcmd/graph.go33
1 files changed, 3 insertions, 30 deletions
diff --git a/src/cmd/go/internal/modcmd/graph.go b/src/cmd/go/internal/modcmd/graph.go
index b123454d60..5825c6d8ca 100644
--- a/src/cmd/go/internal/modcmd/graph.go
+++ b/src/cmd/go/internal/modcmd/graph.go
@@ -18,25 +18,15 @@ import (
)
var cmdGraph = &base.Command{
- UsageLine: "go mod graph [-dot]",
+ UsageLine: "go mod graph",
Short: "print module requirement graph",
Long: `
Graph prints the module requirement graph (with replacements applied)
in text form. Each line in the output has two space-separated fields: a module
and one of its requirements. Each module is identified as a string of the form
path@version, except for the main module, which has no @version suffix.
-
-The -dot flag generates the output in graphviz format that can be used
-with a tool like dot to visually render the dependency graph.
`,
-}
-
-var (
- graphDot = cmdGraph.Flag.Bool("dot", false, "")
-)
-
-func init() {
- cmdGraph.Run = runGraph // break init cycle
+ Run: runGraph,
}
func runGraph(cmd *base.Command, args []string) {
@@ -61,21 +51,10 @@ func runGraph(cmd *base.Command, args []string) {
work.Add(modload.Target)
work.Do(1, func(item interface{}) {
m := item.(module.Version)
- if *graphDot {
- if m.Version == "" {
- out = append(out, "\""+m.Path+"\" [label=<"+m.Path+">]\n")
- } else {
- out = append(out, "\""+m.Path+"\" [label=<"+m.Path+"<br/><font point-size=\"9\">"+m.Version+"</font>>]\n")
- }
- }
list, _ := reqs.Required(m)
for _, r := range list {
work.Add(r)
- if *graphDot {
- out = append(out, "\""+m.Path+"\" -> \""+r.Path+"\"\n")
- } else {
- out = append(out, format(m)+" "+format(r)+"\n")
- }
+ out = append(out, format(m)+" "+format(r)+"\n")
}
if m == modload.Target {
deps = len(out)
@@ -87,14 +66,8 @@ func runGraph(cmd *base.Command, args []string) {
})
w := bufio.NewWriter(os.Stdout)
- if *graphDot {
- w.WriteString("digraph deps {\nrankdir=LR\n")
- }
for _, line := range out {
w.WriteString(line)
}
- if *graphDot {
- w.WriteString("}\n")
- }
w.Flush()
}