refactor: using slices.Contains to simplify the code

Signed-off-by: damuzhi0810 <rust@before.tech>
This commit is contained in:
damuzhi0810 2025-01-23 23:32:10 +08:00 committed by Mike Farah
parent ba1b9737b6
commit 1395d6e230

View File

@ -3,6 +3,7 @@ package yqlib
import (
"fmt"
"path/filepath"
"slices"
"strings"
)
@ -95,12 +96,7 @@ func (f *Format) MatchesName(name string) bool {
if f.FormalName == name {
return true
}
for _, n := range f.Names {
if n == name {
return true
}
}
return false
return slices.Contains(f.Names, name)
}
func (f *Format) GetConfiguredEncoder() Encoder {