diff --git a/dag/graph.go b/dag/graph.go index b271339ba..012118057 100644 --- a/dag/graph.go +++ b/dag/graph.go @@ -202,16 +202,17 @@ func (g *Graph) StringWithNodeTypes() string { // Alphabetize dependencies deps := make([]string, 0, targets.Len()) - targetNodes := make([]Vertex, 0, targets.Len()) + targetNodes := make(map[string]Vertex) for _, target := range targets.List() { - deps = append(deps, VertexName(target)) - targetNodes = append(targetNodes, target) + dep := VertexName(target) + deps = append(deps, dep) + targetNodes[dep] = target } sort.Strings(deps) // Write dependencies - for i, d := range deps { - buf.WriteString(fmt.Sprintf(" %s - %T\n", d, targetNodes[i])) + for _, d := range deps { + buf.WriteString(fmt.Sprintf(" %s - %T\n", d, targetNodes[d])) } }