summaryrefslogtreecommitdiff
path: root/sort.go
diff options
context:
space:
mode:
Diffstat (limited to 'sort.go')
-rw-r--r--sort.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/sort.go b/sort.go
index ff7026b..e6ec300 100644
--- a/sort.go
+++ b/sort.go
@@ -32,9 +32,9 @@ func makeSortfile() {
sortmap["append"] = sortmap["sortKey"]
iterAppend(f, sortmap) // Append() enforce unique key argv.Append
- // add ReplaceKey()
iterDelete(f, sortmap)
iterReplace(f, sortmap)
+ iterFind(f, sortmap)
}
iterEnd(f, sortmap)
}
@@ -239,3 +239,19 @@ func iterDelete(w io.Writer, names map[string]string) {
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
}
+
+func iterFind(w io.Writer, names map[string]string) {
+ fmt.Fprintln(w, "// find a dependancy by the go path")
+ fmt.Fprintln(w, "func (all *"+names["Bases"]+") FindBy"+names["append"]+"(s string) *"+names["Base"]+" {")
+ fmt.Fprintln(w, " "+names["lock"]+".Lock()")
+ fmt.Fprintln(w, " defer "+names["lock"]+".Unlock()")
+ fmt.Fprintln(w, "")
+ fmt.Fprintln(w, " for i, _ := range all."+names["Bases"]+" {")
+ fmt.Fprintln(w, " if all."+names["Bases"]+"[i]."+names["append"]+" == s {")
+ fmt.Fprintln(w, " return all."+names["Bases"]+"[i]")
+ fmt.Fprintln(w, " }")
+ fmt.Fprintln(w, " }")
+ fmt.Fprintln(w, " return nil")
+ fmt.Fprintln(w, "}")
+ fmt.Fprintln(w, "")
+}