1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-05-14 04:16:08 +02:00

fix: dont modify slices in a loop (#554)

This commit is contained in:
Dj Gilcrease 2022-09-29 07:49:55 -07:00 committed by GitHub
parent a7a2df2794
commit 8a1b1fcc04
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

11
nfpm.go
View File

@ -149,18 +149,15 @@ func (c *Config) Validate() error {
return nil
}
func remove(slice []string, s int) []string {
return append(slice[:s], slice[s+1:]...)
}
func (c *Config) expandEnvVarsStringSlice(items []string) []string {
for i, dep := range items {
val := strings.TrimSpace(os.Expand(dep, c.envMappingFunc))
items[i] = val
}
for i, val := range items {
if val == "" {
items = remove(items, i)
for i := 0; i < len(items); i++ {
if items[i] == "" {
items = append(items[:i], items[i+1:]...)
i-- // Since we just deleted items[i], we must redo that index
}
}

View File

@ -352,6 +352,8 @@ overrides:
depends:
- ${PKG}
- package (= ${VERSION})
- ${PKG}
- ${PKG}
rpm:
depends:
- package = ${VERSION}