Standard library / go/token

go/token.File

Tracks one source file and its line offsets. Expected stdout: 'demo.go\n'.

Formal Syntax & Structure

go syntaxgo
type File 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(f.Name())}
Go Reference