Golang go/token.FileSet.Read function examples

package go/token

Read calls decode to deserialize a file set into s; s must not be nil.

Golang go/token.FileSet.Read function usage examples

Example 1:

 x.fset = token.NewFileSet()
 decode := func(x interface{}) error {
 return gob.NewDecoder(r).Decode(x)
 }
 if err := x.fset.Read(decode); err != nil {
 return n, err
 }

Example 2:

 w.fileSet = token.NewFileSet()
 if err := w.fileSet.Read(json.NewDecoder(bytes.NewReader(pkg.FileSet)).Decode); err != nil {
 panic(err)
 }

Reference :

http://golang.org/pkg/go/token/#FileSet.Read

Advertisement