From 1395d6e2305ebea572b2ce46d648b840491204c1 Mon Sep 17 00:00:00 2001 From: damuzhi0810 Date: Thu, 23 Jan 2025 23:32:10 +0800 Subject: [PATCH] refactor: using slices.Contains to simplify the code Signed-off-by: damuzhi0810 --- pkg/yqlib/format.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/yqlib/format.go b/pkg/yqlib/format.go index 144aac08..40bdf346 100644 --- a/pkg/yqlib/format.go +++ b/pkg/yqlib/format.go @@ -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 {