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) *FileParameters & Attributes
| Name | Type | Description |
|---|---|---|
| filename | string | Source filename used in diagnostics. |
| base | int | Starting position of the file; a negative value selects the next available base. |
| size | int | Source 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())}