Standard library / go/token

go/token.FileSet

Maps compact positions to disjoint file intervals. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type FileSet struct {}

Working 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(s.File(f.Pos(1)) == f)}
Go Reference