From 998607134285cb7934f8be8d279ab9e744dd69ca Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Wed, 12 Jul 2023 16:33:10 +0800 Subject: [PATCH 1/2] fix: fmt modify --- engine/resources/packagekit/packagekit.go | 2 +- lang/ast/structs.go | 6 +++--- lang/funcs/core/fmt/printf_func.go | 2 +- pgraph/util_test.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/resources/packagekit/packagekit.go b/engine/resources/packagekit/packagekit.go index 9ac7c6ea1..27f29e48c 100644 --- a/engine/resources/packagekit/packagekit.go +++ b/engine/resources/packagekit/packagekit.go @@ -208,7 +208,7 @@ func (obj *Conn) matchSignal(ch chan *dbus.Signal, path dbus.ObjectPath, iface s // TODO: if we make this call many times, we seem to receive signals // that many times... Maybe this should be an object singleton? var call *dbus.Call - pathStr := fmt.Sprintf("%s", path) + pathStr := path if len(signals) == 0 { args := fmt.Sprintf("type='signal', path='%s', interface='%s'", pathStr, iface) argsList = append(argsList, args) diff --git a/lang/ast/structs.go b/lang/ast/structs.go index c46208fb2..cb9189d7e 100644 --- a/lang/ast/structs.go +++ b/lang/ast/structs.go @@ -6566,7 +6566,7 @@ func (obj *ExprFunc) String() string { var a []string for _, x := range obj.Args { - a = append(a, fmt.Sprintf("%s", x.String())) + a = append(a, x.String()) } args := strings.Join(a, ", ") s := fmt.Sprintf("func(%s)", args) @@ -7213,7 +7213,7 @@ func (obj *ExprFunc) Graph() (*pgraph.Graph, error) { var once bool edgeGenFn := func(v1, v2 pgraph.Vertex) pgraph.Edge { if once { - panic(fmt.Sprintf("edgeGenFn for func was called twice")) + panic("edgeGenFn for func was called twice") } once = true return edge @@ -7332,7 +7332,7 @@ type ExprCall struct { func (obj *ExprCall) String() string { var s []string for _, x := range obj.Args { - s = append(s, fmt.Sprintf("%s", x.String())) + s = append(s, x.String()) } return fmt.Sprintf("call:%s(%s)", obj.Name, strings.Join(s, ", ")) } diff --git a/lang/funcs/core/fmt/printf_func.go b/lang/funcs/core/fmt/printf_func.go index fb615280e..be8ed4ae1 100644 --- a/lang/funcs/core/fmt/printf_func.go +++ b/lang/funcs/core/fmt/printf_func.go @@ -168,7 +168,7 @@ func (obj *PrintfFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, erro } if k := value.Type().Kind; k != types.KindStr { - return nil, fmt.Errorf("unable to build function with 0th arg of kind: %s", k) + return nil, fmt.Errorf("unable to build function with 0th arg of kind: %d", k) } format := value.Str() // must not panic typList, err := parseFormatToTypeList(format) diff --git a/pgraph/util_test.go b/pgraph/util_test.go index 75d3a81a5..7b92441c7 100644 --- a/pgraph/util_test.go +++ b/pgraph/util_test.go @@ -74,7 +74,7 @@ func runGraphCmp(t *testing.T, g1, g2 *Graph) string { str := "" str += fmt.Sprintf(" actual (g1): %v%s", g1, fullPrint(g1)) str += fmt.Sprintf("expected (g2): %v%s", g2, fullPrint(g2)) - str += fmt.Sprintf("cmp error:") + str += "cmp error:" str += fmt.Sprintf("%v", err) return str } From 3f6ba070c6b5fcd8b93c96c44c49d16b6c82b9e5 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Fri, 11 Aug 2023 09:42:17 +0800 Subject: [PATCH 2/2] fix: incorrect modify fmt --- lang/funcs/core/fmt/printf_func.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/funcs/core/fmt/printf_func.go b/lang/funcs/core/fmt/printf_func.go index be8ed4ae1..fb615280e 100644 --- a/lang/funcs/core/fmt/printf_func.go +++ b/lang/funcs/core/fmt/printf_func.go @@ -168,7 +168,7 @@ func (obj *PrintfFunc) Unify(expr interfaces.Expr) ([]interfaces.Invariant, erro } if k := value.Type().Kind; k != types.KindStr { - return nil, fmt.Errorf("unable to build function with 0th arg of kind: %d", k) + return nil, fmt.Errorf("unable to build function with 0th arg of kind: %s", k) } format := value.Str() // must not panic typList, err := parseFormatToTypeList(format)