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
+33.7k Golang : All update packages with go get command
+5.3k Golang : Get FX sentiment from website example
+36.5k Golang : Save image to PNG, JPEG or GIF format.
+5.8k Golang : Launching your executable inside a console under Linux
+14.8k Golang : Find commonalities in two slices or arrays example
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+5.8k Linux : Disable and enable IPv4 forwarding
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+7.3k Golang : alternative to os.Exit() function
+21.2k Golang : Convert(cast) string to rune and back to string example
+13.4k Golang : Verify token from Google Authenticator App
+14.5k Golang : Rename directory