Get name: /first(first|second)*/ Do not set d.err if the name is missing (unless unexpected EOF is received): let the caller provide better context.
()
| 1177 | // Do not set d.err if the name is missing (unless unexpected EOF is received): |
| 1178 | // let the caller provide better context. |
| 1179 | func (d *Decoder) name() (s string, ok bool) { |
| 1180 | d.buf.Reset() |
| 1181 | if !d.readName() { |
| 1182 | return "", false |
| 1183 | } |
| 1184 | |
| 1185 | // Now we check the characters. |
| 1186 | b := d.buf.Bytes() |
| 1187 | if !isName(b) { |
| 1188 | d.err = d.syntaxError("invalid XML name: " + string(b)) |
| 1189 | return "", false |
| 1190 | } |
| 1191 | return string(b), true |
| 1192 | } |
| 1193 | |
| 1194 | // Read a name and append its bytes to d.buf. |
| 1195 | // The name is delimited by any single-byte character not valid in names. |
no test coverage detected