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
+18.5k Golang : Send email with attachment
+17.9k Golang : Simple client server example
+11.6k Golang : Fuzzy string search or approximate string matching example
+19.6k Golang : Set or Add HTTP Request Headers
+6.3k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+14k Golang : convert rune to unicode hexadecimal value and back to rune character
+13.4k Golang : Read from buffered reader until specific number of bytes
+13.3k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+9.6k Golang : Read file with ioutil
+4.6k Mac OSX : Get disk partitions' size, type and name
+10k Golang : Channels and buffered channels examples