Standard library / encoding/xml
encoding/xml.Decoder.InputOffset()
Reports the byte offset at the end of the last returned token and start of the next. Expected stdout: '3\n'.
Formal Syntax & Structure
go syntaxgo
func (d *Decoder) InputOffset() int64Return Value
int64
Byte offset.
Working Example
Example Snippetgo
package main
import ( "encoding/xml" "fmt" "strings")
func must(e error) { if e != nil { panic(e) }}
func main() { d := xml.NewDecoder(strings.NewReader("<a>Go</a>")) _, e := d.Token() must(e) fmt.Println(d.InputOffset())}