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
+13.3k Golang : Linear algebra and matrix calculation example
+48.5k Golang : Upload file from web browser to server
+11.3k Golang : How to flush a channel before the end of program?
+4.6k MariaDB/MySQL : How to get version information
+20.6k Golang : Secure(TLS) connection between server and client
+9.5k Mac OSX : Get a process/daemon status information
+9.4k Golang : Qt Yes No and Quit message box example
+8.2k Golang : Routes multiplexer routing example with regular expression control
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+36.3k Golang : Convert(cast) int64 to string
+14.4k Golang : On enumeration
+6.1k Golang : Build new URL for named or registered route with Gorilla webtoolkit example