1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-05-28 18:16:30 +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 return nil
} }
func remove(slice []string, s int) []string {
return append(slice[:s], slice[s+1:]...)
}
func (c *Config) expandEnvVarsStringSlice(items []string) []string { func (c *Config) expandEnvVarsStringSlice(items []string) []string {
for i, dep := range items { for i, dep := range items {
val := strings.TrimSpace(os.Expand(dep, c.envMappingFunc)) val := strings.TrimSpace(os.Expand(dep, c.envMappingFunc))
items[i] = val items[i] = val
} }
for i, val := range items { for i := 0; i < len(items); i++ {
if val == "" { if items[i] == "" {
items = remove(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: depends:
- ${PKG} - ${PKG}
- package (= ${VERSION}) - package (= ${VERSION})
- ${PKG}
- ${PKG}
rpm: rpm:
depends: depends:
- package = ${VERSION} - package = ${VERSION}