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