Standard library / go/token

go/token.FileSet.AddFile()

Reserves a disjoint compact position interval including EOF. Negative base selects the next available base. Expected stdout: '1 5\n'.

Formal Syntax & Structure

go syntaxgo
func (s *FileSet) AddFile(filename string, base, size int) *File

Parameters & Attributes

NameTypeDescription
filenamestringSource filename used in diagnostics.
baseintStarting position of the file; a negative value selects the next available base.
sizeintSource length in bytes.

Return Value

*File

Reserves a disjoint compact position interval including EOF.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/token")
func main() {  s := token.NewFileSet()  a := s.AddFile("a.go", -1, 3)  b := s.AddFile("b.go", -1, 2)  fmt.Println(a.Base(), b.Base())}
Go Reference