now using the awesome golang 1.24 'iter'
This commit is contained in:
parent
b587843836
commit
f87da2b041
16
wit.go
16
wit.go
|
@ -7,9 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *Machine) IsInstalled(name string) bool {
|
func (m *Machine) IsInstalled(name string) bool {
|
||||||
loop := m.Packages.SortByName()
|
for p := range m.Packages.IterByName() {
|
||||||
for loop.Scan() {
|
|
||||||
p := loop.Next()
|
|
||||||
if name == p.Name {
|
if name == p.Name {
|
||||||
// log.Info("package installed:", p.Name, p.Version, p.PkgName)
|
// log.Info("package installed:", p.Name, p.Version, p.PkgName)
|
||||||
return true
|
return true
|
||||||
|
@ -21,9 +19,7 @@ func (m *Machine) IsInstalled(name string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Machine) FindInstalledByName(name string) *Package {
|
func (m *Machine) FindInstalledByName(name string) *Package {
|
||||||
loop := m.Packages.SortByName()
|
for p := range m.Packages.IterByName() {
|
||||||
for loop.Scan() {
|
|
||||||
p := loop.Next()
|
|
||||||
if name == p.Name {
|
if name == p.Name {
|
||||||
// log.Info("package installed:", p.Name, p.Version, p.PkgName)
|
// log.Info("package installed:", p.Name, p.Version, p.PkgName)
|
||||||
return p
|
return p
|
||||||
|
@ -38,9 +34,7 @@ func (m *Machine) FindInstalledByName(name string) *Package {
|
||||||
// if version == "", return the first name found
|
// if version == "", return the first name found
|
||||||
func (m *Machine) FindVersion(name string, version string) *Package {
|
func (m *Machine) FindVersion(name string, version string) *Package {
|
||||||
// first check all installed versions
|
// first check all installed versions
|
||||||
loop := m.Packages.SortByName()
|
for p := range m.Packages.IterByName() {
|
||||||
for loop.Scan() {
|
|
||||||
p := loop.Next()
|
|
||||||
if name == p.Name {
|
if name == p.Name {
|
||||||
if version == "" {
|
if version == "" {
|
||||||
return p
|
return p
|
||||||
|
@ -53,9 +47,7 @@ func (m *Machine) FindVersion(name string, version string) *Package {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check all wit packages
|
// check all wit packages
|
||||||
loop = m.Wit.SortByName()
|
for p := range m.Wit.IterByName() {
|
||||||
for loop.Scan() {
|
|
||||||
p := loop.Next()
|
|
||||||
if name == p.Name {
|
if name == p.Name {
|
||||||
if version == "" {
|
if version == "" {
|
||||||
return p
|
return p
|
||||||
|
|
Loading…
Reference in New Issue