Standard library / go/token
go/token.File.Name()
Returns the registered filename. Expected stdout: 'demo.go\n'.
Formal Syntax & Structure
go syntaxgo
func (f *File) Name() stringReturn Value
string
Returns the registered filename.
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())}