parent
3f50c54d09
commit
58f595f10f
18
sort.go
18
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, "")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue