Standard library / go/token
go/token.File.MergeLine()
Merges a physical line with its successor without changing byte offsets; invalid line numbers panic. Expected stdout: '[0]\n'.
Formal Syntax & Structure
go syntaxgo
func (f *File) MergeLine(line int)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| line | int | One-based source line number. |
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")) f.MergeLine(1) fmt.Println(f.Lines())}