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
+4.7k Adding Skype actions such as call and chat into web page examples
+20.2k Golang : How to get struct tag and use field name to retrieve data?
+19.2k Golang : Execute shell command
+16.8k Golang : Get own process identifier
+16.5k Golang : Execute terminal command to remote machine example
+9.8k Golang : Qt get screen resolution and display on center example
+7.3k Golang : Of hash table and hash map
+12.3k Golang : 2 dimensional array example
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+37.7k Golang : Comparing date or timestamp
+21.1k Golang : Sort and reverse sort a slice of strings
+8.8k Yum Error: no such table: packages