Golang go/token.File.Name function examples

package go/token

Name returns the file name of file f as registered with AddFile.

Golang go/token.File.Name function usage examples

Example 1:

 if file := x.fset.File(p); file != nil {
 if base := file.Base(); base <= m[1] && m[1] <= base+file.Size() {
  // match [m[0], m[1]) is within the file boundaries
  list[found].filename = file.Name()
  list[found].line = file.Line(p)
  found++
 }
 }

Example 2:

 case name:
 check.files = append(check.files, file)
 var comment string
  if pos := file.Pos(); pos.IsValid() {
 comment = "file " + check.fset.File(pos).Name()
  } else {
 comment = fmt.Sprintf("file[%d]", i)
  }

Reference :

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

Advertisement