Standard library / go/token
go/token.File.AddLineColumnInfo()
Registers alternative filename, line and byte-column information at an increasing offset. Expected stdout: 'virtual.go:20:5\n'.
Formal Syntax & Structure
go syntaxgo
func (f *File) AddLineColumnInfo(offset int, filename string, line, column int)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| offset | int | Zero-based byte offset within the source file. |
| filename | string | Source filename used in diagnostics. |
| line | int | One-based source line number. |
| column | int | One-based byte column, or zero if unknown. |
Working Example
Example Snippetgo
package main
import ( "fmt" "go/token")
func main() { s := token.NewFileSet() f := s.AddFile("demo.go", -1, 5) f.AddLineColumnInfo(1, "virtual.go", 20, 4) fmt.Println(f.Position(f.Pos(2)))}