From 2a0e5deaddac1666dea4e4c3590a54d8208dea65 Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Wed, 20 Mar 2024 21:36:25 +0100 Subject: [PATCH] Revert "fix bug about not support more operations on string (#21)" (#28) This reverts commit d840a145b9f262e1fac81f8f5deecf3d9f2ae39a. --- .gitignore | 2 -- tests/main.go | 7 +------ visitor.go | 4 ++++ 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a9d34d9..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea -goconst \ No newline at end of file diff --git a/tests/main.go b/tests/main.go index 3e28292..d43e983 100644 --- a/tests/main.go +++ b/tests/main.go @@ -27,12 +27,7 @@ func testCase() string { case "moo": return "" } - - test2 := "moo" + fmt.Sprintf("%d", testInt()) - if test2 > "foo" { - test2 += "foo" - } - return "foo" + test2 + return "foo" } func testInt() int { diff --git a/visitor.go b/visitor.go index a553814..c0974da 100644 --- a/visitor.go +++ b/visitor.go @@ -62,6 +62,10 @@ func (v *treeVisitor) Visit(node ast.Node) ast.Visitor { // if foo == "moo" case *ast.BinaryExpr: + if t.Op != token.EQL && t.Op != token.NEQ { + return v + } + var lit *ast.BasicLit var ok bool