blob: c30aa38360b00e661218894e6ad5a46a12af316e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package source
import (
"bytes"
"fmt"
)
type ByteSource struct {
Name string
Content []byte
}
func (b *ByteSource) String() string {
return fmt.Sprintf("%s %s", b.Name, string(b.Content))
}
type InMemorySource struct {
ByteSource []ByteSource
}
func (i *InMemorySource) Files() (files []*File) {
files = make([]*File, len(i.ByteSource))
for i, fake := range i.ByteSource {
files[i] = NewFileWithContents(fake.Name, bytes.NewReader(fake.Content))
}
return
}
|