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
+30.4k Golang : How to verify uploaded file is image or allowed file types
+21.7k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+6.6k Golang : How to determine if request or crawl is from Google robots
+6.9k Nginx : Password protect a directory/folder
+6k Golang : Convert Chinese UTF8 characters to Pin Yin
+8.3k Golang : Oanda bot with Telegram and RSI example
+11.9k Golang : Convert(cast) bigint to string
+16k Golang : How to reverse elements order in map ?
+5.3k Swift : Convert string array to array example
+9k Golang : How to use Gorilla webtoolkit context package properly
+22.1k Golang : Join arrays or slices example
+13.3k Golang : Date and Time formatting