diff --git a/builder/config.go b/builder/config.go index 38c140c..adb7204 100644 --- a/builder/config.go +++ b/builder/config.go @@ -21,6 +21,7 @@ import ( "io" "os" "path/filepath" + "slices" "github.com/BurntSushi/toml" ) @@ -58,8 +59,8 @@ func NewConfig() (*Config, error) { } // Reverse because /etc takes precedence in stateless - for i := len(ConfigPaths) - 1; i >= 0; i-- { - globPat := filepath.Join(ConfigPaths[i], fmt.Sprintf("*%s", ConfigSuffix)) + for _, path := range slices.Backward(ConfigPaths) { + globPat := filepath.Join(path, fmt.Sprintf("*%s", ConfigSuffix)) configs, _ := filepath.Glob(globPat) diff --git a/builder/main.go b/builder/main.go index 057c880..fb60d5c 100644 --- a/builder/main.go +++ b/builder/main.go @@ -21,6 +21,7 @@ import ( "fmt" "os" "path/filepath" + "slices" ) // DisableColors controls whether or not to use colours in the display. @@ -54,9 +55,11 @@ const ( // CacheDirectory is where packages' build cache are stored. CacheDirectory = "/var/lib/solbuild/cache" - // Obsolete cache directories. These are only still specified so that the - // `delete-cache -a` subcommand will remove them. In the future they will - // be removed. + /* Obsolete cache directories. These are only still specified so that the + * `delete-cache -a` subcommand will remove them. In the future they will + * be removed. + */ + ObsoleteCcacheDirectory = "/var/lib/solbuild/ccache/ypkg" ObsoleteLegacyCcacheDirectory = "/var/lib/solbuild/ccache/legacy" ObsoleteSccacheDirectory = "/var/lib/solbuild/sccache/ypkg" @@ -100,13 +103,7 @@ func PathExists(path string) bool { // IsValidImage will check if the specified profile is a valid one. func IsValidImage(profile string) bool { - for _, p := range ValidImages { - if p == profile { - return true - } - } - - return false + return slices.Contains(ValidImages, profile) } // EmitImageError emits the stock response to requesting an invalid image. diff --git a/builder/util.go b/builder/util.go index f0a130c..9e13a6b 100644 --- a/builder/util.go +++ b/builder/util.go @@ -378,10 +378,8 @@ func ValidMemSize(s string) bool { lastChar := s[len(s)-1:] validLastChars := []string{"G", "T", "P", "E"} - for _, v := range validLastChars { - if v == lastChar { - return true - } + if slices.Contains(validLastChars, lastChar) { + return true } slog.Error(fmt.Sprintf("Invalid Memory Size: %s doesn't end in a valid memory unit, e.g. G\n", s))