diff --git a/appconfig/appconfig.go b/appconfig/appconfig.go index 65438c6..126e5b6 100644 --- a/appconfig/appconfig.go +++ b/appconfig/appconfig.go @@ -153,15 +153,16 @@ func (c *AppConfig) GetConfigDesc() []string { } } - filter := "Filter: " + var filterBuilder strings.Builder + filterBuilder.WriteString("Filter: ") if len(c.Filter) > 0 { for _, f := range c.Filter { - filter += fmt.Sprintf("\n %s", f) + filterBuilder.WriteString(fmt.Sprintf("\n %s", f)) } } else { - filter += "None" + filterBuilder.WriteString("None") } - desc = append(desc, filter) + desc = append(desc, filterBuilder.String()) return desc } diff --git a/installer/github_release_installer.go b/installer/github_release_installer.go index 50f05fd..7446c5a 100644 --- a/installer/github_release_installer.go +++ b/installer/github_release_installer.go @@ -61,10 +61,8 @@ func (i *GitHubReleaseInstaller) Validate() []ValidationError { } if opts.DownloadFilename == nil || len(*opts.DownloadFilename.Resolve()) == 0 { errors = append(errors, ValidationError{FieldName: "download_filename", Message: validationIsRequired(), InstallerName: *info.Name}) - } else { - if (*opts.DownloadFilename).Resolve() == nil || len(*(*opts.DownloadFilename).Resolve()) == 0 { - errors = append(errors, ValidationError{FieldName: fmt.Sprintf("download_filename.%s", platform.GetPlatform()), Message: validationIsRequired(), InstallerName: *info.Name}) - } + } else if (*opts.DownloadFilename).Resolve() == nil || len(*(*opts.DownloadFilename).Resolve()) == 0 { + errors = append(errors, ValidationError{FieldName: fmt.Sprintf("download_filename.%s", platform.GetPlatform()), Message: validationIsRequired(), InstallerName: *info.Name}) } if opts.Strategy != nil { if *opts.Strategy != GitHubReleaseInstallStrategyNone && *opts.Strategy != GitHubReleaseInstallStrategyTar && *opts.Strategy != GitHubReleaseInstallStrategyZip { diff --git a/platform/platform.go b/platform/platform.go index e86272f..b9c1bdc 100644 --- a/platform/platform.go +++ b/platform/platform.go @@ -163,8 +163,8 @@ func ParselatformMap[T any](values map[string]T) *PlatformMap[T] { // NewPlatformMap creates a new PlatformMap from either a single value or a map. func NewPlatformMap[T any](input any) *PlatformMap[T] { switch v := input.(type) { - case T: - return ParsePlatformSingleValue(v) + case nil: + return nil case *T: if v != nil { return ParsePlatformSingleValue(*v) @@ -180,8 +180,8 @@ func NewPlatformMap[T any](input any) *PlatformMap[T] { } } return ParselatformMap(flat) - case nil: - return nil + case T: + return ParsePlatformSingleValue(v) default: panic(fmt.Sprintf("NewPlatformMap: unsupported input type %T", input)) } diff --git a/utils/env.go b/utils/env.go index 2baed65..8b199d5 100644 --- a/utils/env.go +++ b/utils/env.go @@ -2,6 +2,7 @@ package utils import ( "fmt" + "maps" "strings" ) @@ -39,9 +40,7 @@ func CombineEnvMaps(envs ...*map[string]string) map[string]string { if env == nil { continue } - for k, v := range *env { - out[k] = v - } + maps.Copy(out, *env) } return out } @@ -77,8 +76,6 @@ func mergeEnvs(source *[]string, target []string) []string { if source == nil { source = &[]string{} // Treat nil source as empty } - for k, v := range EnvSliceAsMap(*source) { - tgt[k] = v // Override or add keys from source - } + maps.Copy(tgt, EnvSliceAsMap(*source)) return EnvMapAsSlice(tgt) }