1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 type serializedFile
struct {
8 // fields correspond 1:1 to fields with same (lower-case) name in File
16 type serializedFileSet
struct {
18 Files
[]serializedFile
21 // Read calls decode to deserialize a file set into s; s must not be nil.
22 func (s
*FileSet
) Read(decode
func(interface{}) error
) error
{
23 var ss serializedFileSet
24 if err
:= decode(&ss
); err
!= nil {
30 files
:= make([]*File
, len(ss
.Files
))
31 for i
:= 0; i
< len(ss
.Files
); i
++ {
49 // Write calls encode to serialize the file set s.
50 func (s
*FileSet
) Write(encode
func(interface{}) error
) error
{
51 var ss serializedFileSet
55 files
:= make([]serializedFile
, len(s
.files
))
56 for i
, f
:= range s
.files
{
58 files
[i
] = serializedFile
{
62 Lines
: append([]int(nil), f
.lines
...),
63 Infos
: append([]lineInfo(nil), f
.infos
...),