Skip to content

Commit

Permalink
Improvements after review
Browse files Browse the repository at this point in the history
  • Loading branch information
jgautheron committed Nov 8, 2020
1 parent ce0d7c0 commit b58d7cf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions visitor.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package goconst

import (
"fmt"
"go/ast"
"go/token"
"strconv"
"strings"
)

Expand Down Expand Up @@ -112,13 +112,11 @@ func (v *treeVisitor) Visit(node ast.Node) ast.Visitor {

// addString adds a string in the map along with its position in the tree.
func (v *treeVisitor) addString(str string, pos token.Pos) {
// Drop quotes if any
if strings.HasPrefix(str, `"`) || strings.HasPrefix(str, "`") {
// Drop first and last character, quote, backquote...
str = str[1 : len(str)-1]
str, _ = strconv.Unquote(str)
}

fmt.Println(str)

// Ignore empty strings
if len(str) == 0 {
return
Expand Down

0 comments on commit b58d7cf

Please sign in to comment.