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
+12.7k Golang : Sort and reverse sort a slice of bytes
+8.4k Golang : Convert word to its plural form example
+10.6k Golang : Select region of interest with mouse click and crop from image
+12.6k Golang : Transform comma separated string to slice example
+8.1k Golang : Randomize letters from a string example
+10.8k Android Studio : Checkbox for user to select options example
+18.6k Golang : Get download file size
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+7.9k Golang : Get today's weekday name and calculate target day distance example
+11.3k Golang : Intercept and process UNIX signals example
+6.6k Golang : Embedded or data bundling example
+26.8k Golang : Convert file content into array of bytes