Standard library / go/token

go/token.File.Base()

Returns the file base assigned during AddFile. Expected stdout: '1\n'.

Formal Syntax & Structure

go syntaxgo
func (f *File) Base() int

Return Value

int

Returns the file base assigned during AddFile.

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.Base())}
Go Reference