Golang go/token.File.SetLinesForContent function example
package go/token
SetLinesForContent sets the line offsets for the given file content.
Golang go/token.File.SetLinesForContent function usage example
Example 1:
var str string
fset := token.NewFileSet()
fset.AddFile("", len(str), fset.Base()).SetLinesForContent([]byte(str))
Example 2:
if util.IsText(src) {
// only add the file to the file set (for the full text index)
file = x.fset.AddFile(filename, x.fset.Base(), len(src))
file.SetLinesForContent(src)
return
}
Reference :
Advertisement
Something interesting
Tutorials
+22.4k Golang : How to read JPG(JPEG), GIF and PNG files ?
+5.9k Golang : Denco multiplexer example
+34.6k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+12.5k Golang : Forwarding a local port to a remote server example
+14.9k Golang : Submit web forms without browser by http.PostForm example
+25.3k Golang : Convert uint value to string type
+18.8k Golang : Implement getters and setters
+15.2k Golang : Save(pipe) HTTP response into a file
+23.9k Golang : Use regular expression to validate domain name
+23.7k Find and replace a character in a string in Go
+33k Golang : How to check if a date is within certain range?
+13.4k Golang : Read from buffered reader until specific number of bytes