Golang go/token.File.Size function examples

package go/token

Size returns the size of file f as registered with AddFile.

Golang go/token.File.Size function usage examples

Example 1:

 // update statistics for data size, number of files and lines processed
 stats.Bytes += file.Size()
 stats.Files++
 stats.Lines += file.LineCount()

Example 2:

 file *token.File
 var src []byte

 // Explicitly initialize all fields since a scanner may be reused.
 if file.Size() != len(src) {
 panic(fmt.Sprintf("file size (%d) does not match src len (%d)", file.Size(), len(src)))
 }

Reference :

http://golang.org/pkg/go/token/#File.Size

Advertisement