diff options
| author | Shulhan <ms@kilabit.info> | 2022-09-07 23:22:23 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-09-07 23:22:23 +0700 |
| commit | c6b0f2520f27bedd36cee06c0d62dffd95f90381 (patch) | |
| tree | ca8bdd4c2868a7efbfc06b7fbc27855b039d450f /lib/text/chunk.go | |
| parent | dd485ce62d0554bddb6f8253ee4700ece6c4ea00 (diff) | |
| download | pakakeh.go-c6b0f2520f27bedd36cee06c0d62dffd95f90381.tar.xz | |
lib/text: replace json.Escape with strconv.Quote
We want to prevent import cycle in the future, when the test package
use the text/diff for display difference between string.
Diffstat (limited to 'lib/text/chunk.go')
| -rw-r--r-- | lib/text/chunk.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/text/chunk.go b/lib/text/chunk.go index 49ab395d..ddf2edc4 100644 --- a/lib/text/chunk.go +++ b/lib/text/chunk.go @@ -8,8 +8,6 @@ import ( "bytes" "fmt" "strconv" - - "github.com/shuLhan/share/lib/json" ) // Chunk represent subset of line, contain starting position and slice of @@ -38,9 +36,9 @@ func (chunk Chunk) MarshalJSON() ([]byte, error) { bb.WriteString(`{"StartAt":`) bb.WriteString(strconv.Itoa(chunk.StartAt)) - bb.WriteString(`,"V":"`) - bb.Write(json.Escape(chunk.V)) - bb.WriteString(`"}`) + bb.WriteString(`,"V":`) + bb.WriteString(strconv.Quote(string(chunk.V))) + bb.WriteString(`}`) return bb.Bytes(), nil } |
