Skip to content

Instantly share code, notes, and snippets.

@DocSavage
Last active August 18, 2017 17:16

Revisions

  1. DocSavage revised this gist Jan 14, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.go
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    // packageList returns the list of packages in the dag rooted at roots
    // as visited in a depth-first post-order traversal.
    func packageList(roots []*Package) []*Package {
    seen := map[*Package]bool{}

    seen := map[*Package]bool{}
    all := []*Package{}
    var walk func(*Package)
    walk = func(p *Package) {
  2. DocSavage revised this gist Jan 14, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.go
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // packageList returns the list of packages in the dag rooted at roots
    // as visited in a depth-first post-order traversal.
    func packageList(roots []*Package) []*Package {
    seen := map[*Package]bool{}
    seen := map[*Package]bool{}
    all := []*Package{}
    var walk func(*Package)
    walk = func(p *Package) {
  3. DocSavage created this gist Jan 14, 2013.
    21 changes: 21 additions & 0 deletions gistfile1.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    // packageList returns the list of packages in the dag rooted at roots
    // as visited in a depth-first post-order traversal.
    func packageList(roots []*Package) []*Package {
    seen := map[*Package]bool{}
    all := []*Package{}
    var walk func(*Package)
    walk = func(p *Package) {
    if seen[p] {
    return
    }
    seen[p] = true
    for _, p1 := range p.imports {
    walk(p1)
    }
    all = append(all, p)
    }
    for _, root := range roots {
    walk(root)
    }
    return all
    }