diff --git a/_fixtures/struct_tags.go b/_fixtures/struct_tags.go index 3e07368..ecdaf3f 100644 --- a/_fixtures/struct_tags.go +++ b/_fixtures/struct_tags.go @@ -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"` diff --git a/_fixtures/struct_tags__exp.go b/_fixtures/struct_tags__exp.go index f9e6e8d..61b5a6b 100644 --- a/_fixtures/struct_tags__exp.go +++ b/_fixtures/struct_tags__exp.go @@ -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"` diff --git a/tags.go b/tags.go index 933e995..4f44aa7 100644 --- a/tags.go +++ b/tags.go @@ -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, "")