github.com/benchkram/bob@v0.0.0-20240314204020-b7a57f2f9be9/pkg/nix/dependency.go (about) 1 package nix 2 3 // UniqueDeps removes duplicates from the list by checking against name-nixpkgs key 4 func UniqueDeps(s []Dependency) []Dependency { 5 added := make(map[string]bool) 6 var res []Dependency 7 for _, v := range s { 8 if _, exists := added[v.Name+v.Nixpkgs]; !exists { 9 res = append(res, v) 10 added[v.Name+v.Nixpkgs] = true 11 } 12 } 13 return res 14 } 15 16 func AppendUnique(a []Dependency, x Dependency) []Dependency { 17 for _, y := range a { 18 if x.Name+x.Nixpkgs == y.Name+y.Nixpkgs { 19 return a 20 } 21 } 22 return append(a, x) 23 }