@@ -65,22 +65,16 @@ func (pkgs *Packages) AddPlatforms(versionedname string, platforms []string) err
65
65
if len (platforms ) == 0 {
66
66
return nil
67
67
}
68
- for _ , platform := range platforms {
69
- if err := nix .EnsureValidPlatform (platform ); err != nil {
70
- return errors .WithStack (err )
71
- }
68
+ if err := nix .EnsureValidPlatform (platforms ... ); err != nil {
69
+ return errors .WithStack (err )
72
70
}
73
71
74
72
name , version := parseVersionedName (versionedname )
75
73
for idx , pkg := range pkgs .Collection {
76
74
if pkg .name == name && pkg .Version == version {
77
75
78
- for _ , platform := range platforms {
79
- // Append if the platform is not already present
80
- if ! lo .SomeBy (pkg .Platforms , func (p string ) bool { return p == platform }) {
81
- pkg .Platforms = append (pkg .Platforms , platform )
82
- }
83
- }
76
+ // Append if the platform is not already present
77
+ pkg .Platforms = lo .Uniq (append (pkg .Platforms , platforms ... ))
84
78
85
79
// Adding any platform will restrict installation to it, so
86
80
// the ExcludedPlatforms are no longer needed
@@ -110,12 +104,7 @@ func (pkgs *Packages) ExcludePlatforms(versionedName string, platforms []string)
110
104
for idx , pkg := range pkgs .Collection {
111
105
if pkg .name == name && pkg .Version == version {
112
106
113
- for _ , platform := range platforms {
114
- // Append if the platform is not already present
115
- if ! lo .SomeBy (pkg .ExcludedPlatforms , func (p string ) bool { return p == platform }) {
116
- pkg .ExcludedPlatforms = append (pkg .ExcludedPlatforms , platform )
117
- }
118
- }
107
+ pkg .ExcludedPlatforms = lo .Uniq (append (pkg .ExcludedPlatforms , platforms ... ))
119
108
if len (pkg .Platforms ) > 0 {
120
109
ux .Finfo (
121
110
os .Stderr ,
0 commit comments