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
+10.6k Golang : Get local time and equivalent time in different time zone
+20.9k Golang : Convert PNG transparent background image to JPG or JPEG image
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+7.4k Android Studio : How to detect camera, activate and capture example
+13.4k Golang : Increment string example
+15.6k Golang : Force download file example
+10.5k Generate Random number with math/rand in Go
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example
+6.4k Golang : How to search a list of records or data structures
+10.3k Golang : Embed secret text string into binary(executable) file
+16.4k Golang : Convert slice to array
+18.8k Golang : Implement getters and setters