chore: use strings.Contains and bytes.Contains instead

pull/1884/head
guoguangwu 1 year ago
parent 88409cc1f0
commit c6e31100b0

@ -1042,14 +1042,14 @@ func (p *printer) marshalStruct(tinfo *typeInfo, val reflect.Value) error {
switch k { switch k {
case reflect.String: case reflect.String:
s := vf.String() s := vf.String()
dashDash = strings.Index(s, "--") >= 0 dashDash = strings.Contains(s, "--")
dashLast = s[len(s)-1] == '-' dashLast = s[len(s)-1] == '-'
if !dashDash { if !dashDash {
p.WriteString(s) p.WriteString(s)
} }
case reflect.Slice: case reflect.Slice:
b := vf.Bytes() b := vf.Bytes()
dashDash = bytes.Index(b, ddBytes) >= 0 dashDash = bytes.Contains(b, ddBytes)
dashLast = b[len(b)-1] == '-' dashLast = b[len(b)-1] == '-'
if !dashDash { if !dashDash {
p.Write(b) p.Write(b)

Loading…
Cancel
Save