Skip to content

Commit

Permalink
Use spreak v0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlif committed Jun 5, 2022
1 parent 1c0dc40 commit e9d454b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
18 changes: 1 addition & 17 deletions extract/extractors/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,21 +384,5 @@ func ExtractStringLiteral(expr ast.Expr) (string, ast.Node) {
}
}

result := prepareString(b.String())
return result, expr
}

func prepareString(s string) string {
var b strings.Builder

for _, r := range s {
switch r {
case '"':
b.WriteString(`\"`)
default:
b.WriteRune(r)
}
}

return b.String()
return b.String(), expr
}
4 changes: 2 additions & 2 deletions extract/extractors/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func TestExtractStringLiteral(t *testing.T) {
{
name: "Backqoutes with qoutes",
code: "`This is an \"Test\" abc`",
wantStr: "This is an \\\"Test\\\" abc",
wantStr: "This is an \"Test\" abc",
wantFound: true,
},
{
name: "Backqoutes with qoutes",
code: `"This is an \"Test\" abc"`,
wantStr: "This is an \\\"Test\\\" abc",
wantStr: "This is an \"Test\" abc",
wantFound: true,
},
{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.1
github.com/vorlif/spreak v0.3.0
github.com/vorlif/spreak v0.3.2
golang.org/x/text v0.3.7
golang.org/x/tools v0.1.10
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/vorlif/spreak v0.3.0 h1:oHmIGV38MDY7ZEHxPevaGxBpUeHgObwWX6p7Rrl79xo=
github.com/vorlif/spreak v0.3.0/go.mod h1:/mYnzorAXrvSyN5a81dWy/e1Xhm+0vGOUHIcq8Wif2w=
github.com/vorlif/spreak v0.3.2 h1:SAF53l0PGl5DfyapT35qSWFRa1rgOW0kISxYHMQRILg=
github.com/vorlif/spreak v0.3.2/go.mod h1:/mYnzorAXrvSyN5a81dWy/e1Xhm+0vGOUHIcq8Wif2w=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down

0 comments on commit e9d454b

Please sign in to comment.