File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ func (t *Tag) Value() string {
277
277
278
278
// String reassembles the tag into a valid tag field representation
279
279
func (t * Tag ) String () string {
280
- return fmt .Sprintf (`%s:"%s" ` , t .Key , t .Value ())
280
+ return fmt .Sprintf (`%s:%q ` , t .Key , t .Value ())
281
281
}
282
282
283
283
// GoString implements the fmt.GoStringer interface
Original file line number Diff line number Diff line change @@ -151,6 +151,17 @@ func TestParse(t *testing.T) {
151
151
},
152
152
},
153
153
},
154
+ {
155
+ name : "tag with quoted name" ,
156
+ tag : `json:"foo,bar:\"baz\""` ,
157
+ exp : []* Tag {
158
+ {
159
+ Key : "json" ,
160
+ Name : "foo" ,
161
+ Options : []string {`bar:"baz"` },
162
+ },
163
+ },
164
+ },
154
165
}
155
166
156
167
for _ , ts := range test {
@@ -167,10 +178,13 @@ func TestParse(t *testing.T) {
167
178
}
168
179
169
180
got := tags .Tags ()
170
-
171
181
if ! reflect .DeepEqual (ts .exp , got ) {
172
182
t .Errorf ("parse\n \t want: %#v\n \t got : %#v" , ts .exp , got )
173
183
}
184
+
185
+ if ts .tag != tags .String () {
186
+ t .Errorf ("parse string\n \t want: %#v\n \t got : %#v" , ts .tag , tags .String ())
187
+ }
174
188
})
175
189
}
176
190
}
You can’t perform that action at this time.
0 commit comments