Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #142 raw literal with backslashes becomes "unescaped" #143

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _fixtures/struct_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type MyStruct struct {
Field1 string `json:"field1" info:"something"`

// Field6 example adapted from https://github.com/segmentio/golines/issues/15.
ALongField2 string `json:"long_field2 ãï" info:"something else ãï" tag:"a really long tag that extends us beyond 100 chars"`
ALongField2 string `json:"long_field2 ãï" info:"something else ãï" tag:"a really long tag that extends us beyond 100 chars \\escaped\\|escaped"`
Field3 string `json:"field3" info:"ãï third thing"`
Field4 string `json:"field3" tag:"ãï something"`
Field5 int `tag:"something else" tag:"something"`
Expand Down
2 changes: 1 addition & 1 deletion _fixtures/struct_tags__exp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type MyStruct struct {
Field1 string `json:"field1" info:"something"`

// Field6 example adapted from https://github.com/segmentio/golines/issues/15.
ALongField2 string `json:"long_field2 ãï" info:"something else ãï" tag:"a really long tag that extends us beyond 100 chars"`
ALongField2 string `json:"long_field2 ãï" info:"something else ãï" tag:"a really long tag that extends us beyond 100 chars \\escaped\\|escaped"`
Field3 string `json:"field3" info:"ãï third thing"`
Field4 string `json:"field3" tag:"ãï something"`
Field5 int ` tag:"something else"`
Expand Down
2 changes: 1 addition & 1 deletion tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func alignTags(fields []*dst.Field) {
lenUsed := 0

if ok {
tagComponents = append(tagComponents, fmt.Sprintf("%s:\"%s\"", key, value))
tagComponents = append(tagComponents, fmt.Sprintf("%s:%q", key, value))
lenUsed += len(key) + tagValueLen(value) + 3
} else {
tagComponents = append(tagComponents, "")
Expand Down