chore: update to use iterators on orderedmaps

This commit is contained in:
Tristan Cartledge
2024-08-14 12:10:07 +01:00
committed by quobix
parent c3eb16d4e4
commit 161a41f73b
73 changed files with 690 additions and 550 deletions

View File

@@ -128,16 +128,14 @@ func (mg *MockGenerator) GenerateMock(mock any, name string) ([]byte, error) {
examplesMap := examplesValue.(*orderedmap.Map[string, *highbase.Example])
// if the name is not empty, try and find the example by name
for pair := orderedmap.First(examplesMap); pair != nil; pair = pair.Next() {
k, exp := pair.Key(), pair.Value()
for k, exp := range examplesMap.FromOldest() {
if k == name {
return mg.renderMock(exp.Value), nil
}
}
// if the name is empty, just return the first example
for pair := orderedmap.First(examplesMap); pair != nil; pair = pair.Next() {
exp := pair.Value()
for exp := range examplesMap.ValuesFromOldest() {
return mg.renderMock(exp.Value), nil
}
}