Standard library / go/token
go/token.Pos
Compact source position relative to a file set; not a raw byte offset. Expected stdout: '4\n'.
Formal Syntax & Structure
go syntaxgo
type Pos intWorking Example
Example Snippetgo
package main
import ( "fmt" "go/token")
func main() { s := token.NewFileSet() f := s.AddFile("demo.go", -1, 5) f.SetLinesForContent([]byte("ab\ncd")) fmt.Println(f.Pos(3))}