Standard library / go/token

go/token.FileSet.RemoveFile()

Removes a file interval from future file-set lookups. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (s *FileSet) RemoveFile(file *File)

Parameters & Attributes

NameTypeDescription
file*FileFile with a size matching the source, or file to remove from the set.

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"))  p := f.Pos(2)  s.RemoveFile(f)  fmt.Println(s.File(p) == nil)}
Go Reference