Standard library / encoding/csv

encoding/csv.Reader.InputOffset()

Return the byte offset at the end of the most recently read row and start of the next. Useful for reporting consumed input. Expected stdout: '4\n'.

Formal Syntax & Structure

go syntaxgo
func (r *Reader) InputOffset() int64

Return Value

int64

Byte offset into the input stream.

Working Example

Example Snippetgo
package main
import (  "encoding/csv"  "fmt"  "strings")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  r := csv.NewReader(strings.NewReader("a,b\nc,d\n"))  _, e := r.Read()  must(e)  fmt.Println(r.InputOffset())}
Go Reference