From f87da2b041b6a1f0464d493e2f1b7fdfc457cf58 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 19 Mar 2025 06:40:36 -0500 Subject: [PATCH] now using the awesome golang 1.24 'iter' --- wit.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/wit.go b/wit.go index 5a11965..352884a 100644 --- a/wit.go +++ b/wit.go @@ -7,9 +7,7 @@ import ( ) func (m *Machine) IsInstalled(name string) bool { - loop := m.Packages.SortByName() - for loop.Scan() { - p := loop.Next() + for p := range m.Packages.IterByName() { if name == p.Name { // log.Info("package installed:", p.Name, p.Version, p.PkgName) return true @@ -21,9 +19,7 @@ func (m *Machine) IsInstalled(name string) bool { } func (m *Machine) FindInstalledByName(name string) *Package { - loop := m.Packages.SortByName() - for loop.Scan() { - p := loop.Next() + for p := range m.Packages.IterByName() { if name == p.Name { // log.Info("package installed:", p.Name, p.Version, p.PkgName) return p @@ -38,9 +34,7 @@ func (m *Machine) FindInstalledByName(name string) *Package { // if version == "", return the first name found func (m *Machine) FindVersion(name string, version string) *Package { // first check all installed versions - loop := m.Packages.SortByName() - for loop.Scan() { - p := loop.Next() + for p := range m.Packages.IterByName() { if name == p.Name { if version == "" { return p @@ -53,9 +47,7 @@ func (m *Machine) FindVersion(name string, version string) *Package { } // check all wit packages - loop = m.Wit.SortByName() - for loop.Scan() { - p := loop.Next() + for p := range m.Wit.IterByName() { if name == p.Name { if version == "" { return p