cmd/aedeploy: don't scan packages more than once

Packages that are imported from several different packages don't need to
be scanned more than once. A real-world project would take 10-20 minutes
to scan before this commit, and about 1-2 seconds now.

Fixes #35.

Change-Id: Icfbf84cfb11e1523f4874c1dc51f294c5cb611bf
diff --git a/cmd/aedeploy/aedeploy.go b/cmd/aedeploy/aedeploy.go
index 95b9f49..7098cbf 100644
--- a/cmd/aedeploy/aedeploy.go
+++ b/cmd/aedeploy/aedeploy.go
@@ -162,6 +162,7 @@
 		path, fromDir string
 	}
 	var imports []importFrom
+	visited := make(map[importFrom]bool)
 
 	pkg, err := ctxt.ImportDir(srcDir, 0)
 	if err != nil {
@@ -178,11 +179,16 @@
 	for len(imports) != 0 {
 		i := imports[0]
 		imports = imports[1:] // shift
-
 		if i.path == "C" {
 			// ignore cgo
 			continue
 		}
+		if _, ok := visited[i]; ok {
+			// already scanned
+			continue
+		}
+		visited[i] = true
+
 		abs, err := filepath.Abs(i.fromDir)
 		if err != nil {
 			return nil, fmt.Errorf("unable to get absolute directory of %q: %v", i.fromDir, err)