From 50afc3cf924c0b545cfe1ba406e172eeba721eef Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Thu, 5 Dec 2024 00:48:38 -0300 Subject: [PATCH] fix: invalid boolean comparsions w/ maps --- cmd/update.go | 4 ++-- drv/brew.go | 19 ++++++++++--------- drv/distrobox.go | 4 ++-- drv/flatpak.go | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/cmd/update.go b/cmd/update.go index f47caf3..906a869 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -57,8 +57,8 @@ func Update(cmd *cobra.Command, args []string) { } initConfiguration := drv.UpdaterInitConfiguration{}.New() - _, empty := os.LookupEnv("CI") - initConfiguration.Ci = !empty + _, exists := os.LookupEnv("CI") + initConfiguration.Ci = exists initConfiguration.DryRun = dryRun initConfiguration.Verbose = verboseRun diff --git a/drv/brew.go b/drv/brew.go index 072c490..c2ad6f4 100644 --- a/drv/brew.go +++ b/drv/brew.go @@ -76,31 +76,32 @@ type BrewUpdater struct { func (up BrewUpdater) New(config UpdaterInitConfiguration) (BrewUpdater, error) { up.Environment = config.Environment - brewPrefix, empty := up.Environment["HOMEBREW_PREFIX"] - if empty || brewPrefix == "" { + + brewPrefix, exists := up.Environment["HOMEBREW_PREFIX"] + if !exists || brewPrefix == "" { up.BrewPrefix = "/home/linuxbrew/.linuxbrew" } else { up.BrewPrefix = brewPrefix } - brewRepo, empty := up.Environment["HOMEBREW_REPOSITORY"] - if empty || brewRepo == "" { + brewRepo, exists := up.Environment["HOMEBREW_REPOSITORY"] + if !exists || brewRepo == "" { up.BrewRepo = fmt.Sprintf("%s/Homebrew", up.BrewPrefix) } else { up.BrewRepo = brewRepo } - brewCellar, empty := up.Environment["HOMEBREW_CELLAR"] - if empty || brewCellar == "" { + brewCellar, exists := up.Environment["HOMEBREW_CELLAR"] + if !exists || brewCellar == "" { up.BrewCellar = fmt.Sprintf("%s/Cellar", up.BrewPrefix) } else { - up.BrewCellar = brewCellar } - brewPath, empty := up.Environment["HOMEBREW_PATH"] - if empty || brewPath == "" { + brewPath, exists := up.Environment["HOMEBREW_PATH"] + if !exists || brewPath == "" { up.BrewPath = fmt.Sprintf("%s/bin/brew", up.BrewPrefix) } else { up.BrewPath = brewPath } + up.Config = DriverConfiguration{ Title: "Brew", Description: "CLI Apps", diff --git a/drv/distrobox.go b/drv/distrobox.go index 277f30d..4ee22bb 100644 --- a/drv/distrobox.go +++ b/drv/distrobox.go @@ -36,8 +36,8 @@ func (up DistroboxUpdater) New(config UpdaterInitConfiguration) (DistroboxUpdate up.usersEnabled = false up.Tracker = nil - binaryPath, empty := config.Environment["UUPD_DISTROBOX_BINARY"] - if empty || binaryPath == "" { + binaryPath, exists := config.Environment["UUPD_DISTROBOX_BINARY"] + if !exists || binaryPath == "" { up.binaryPath = "/usr/bin/distrobox" } else { up.binaryPath = binaryPath diff --git a/drv/flatpak.go b/drv/flatpak.go index 371261c..988efaa 100644 --- a/drv/flatpak.go +++ b/drv/flatpak.go @@ -38,8 +38,8 @@ func (up FlatpakUpdater) New(config UpdaterInitConfiguration) (FlatpakUpdater, e up.usersEnabled = false up.Tracker = nil - binaryPath, empty := config.Environment["UUPD_FLATPAK_BINARY"] - if empty || binaryPath == "" { + binaryPath, exists := config.Environment["UUPD_FLATPAK_BINARY"] + if !exists || binaryPath == "" { up.binaryPath = "/usr/bin/flatpak" } else { up.binaryPath = binaryPath