Skip reads tokens until it has consumed the end element matching the most recent start element already consumed, skipping nested structures. It returns nil if it finds an end element matching the start element; otherwise it returns an error describing the problem.
()
| 772 | // It returns nil if it finds an end element matching the start |
| 773 | // element; otherwise it returns an error describing the problem. |
| 774 | func (d *Decoder) Skip() error { |
| 775 | var depth int64 |
| 776 | for { |
| 777 | tok, err := d.Token() |
| 778 | if err != nil { |
| 779 | return err |
| 780 | } |
| 781 | switch tok.(type) { |
| 782 | case StartElement: |
| 783 | depth++ |
| 784 | case EndElement: |
| 785 | if depth == 0 { |
| 786 | return nil |
| 787 | } |
| 788 | depth-- |
| 789 | } |
| 790 | } |
| 791 | } |
no test coverage detected