Golang go/token.File.MergeLine function examples
package go/token
MergeLine merges a line(1st parameter) with the following line. It is akin to replacing the newline character at the end of the line with a space (to not change the remaining offsets). To obtain the line number, consult e.g. Position.Line. MergeLine will panic if given an invalid line number.
Golang go/token.File.MergeLine function examples
Example 1:
if len(d.Specs) > 0 {
lastSpec := d.Specs[len(d.Specs)-1]
lastLine := fset.Position(lastSpec.Pos()).Line
if rParenLine := fset.Position(d.Rparen).Line; rParenLine > lastLine+1 {
fset.File(d.Rparen).MergeLine(rParenLine - 1) // <-- here
}
}
Example 2:
p := s.Pos()
fset.File(p).MergeLine(fset.Position(p).Line)
Reference :
Advertisement
Something interesting
Tutorials
+51.4k Golang : Check if item is in slice/array
+6.2k Golang & Javascript : How to save cropped image to file on server
+6.1k Golang : Measure execution time for a function
+6.4k Golang : How to search a list of records or data structures
+12.6k Golang : Transform comma separated string to slice example
+13.5k Facebook PHP getUser() returns 0
+6.3k Golang : Selection sort example
+13.4k Golang : Generate Code128 barcode
+6.1k Golang : How to write backslash in string?
+7.3k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+25.6k Golang : convert rune to integer value
+9.4k Android Studio : Indicate progression with ProgressBar example