Radar · Go · Archive · Week 8 · Feb 16 – 22, 2026
go/token: add (*File).String method
Nice to knowtooling
- What changed
token.File.String()now returns a brief description of the file, e.g.,"foo.go(1-0)".- Production impact
- The source does not say.
- Try it
fmt.Println(token.NewFileSet().AddFile("foo.go", -1, 0)).- Source
- github.com/golang/go/issues/76285
Understand it, then run it
token.File.String() now prints a short description of a file instead of a long, unreadable struct. Previously, printing a *token.File produced a verbose output that included the file name, size, and internal slices, which was hard to read. The new method formats the file as "name(base-end)", for example "foo.go(1-0)". This makes debugging and logging easier for beginners who want to see which file a token.File refers to.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed