Example #1
0
func (r *MemoryReader) Read() ([]*file.File, error) {
	result := make([]*file.File, 0, len(r.files))
	for k := range r.files {
		if file, err := file.NewFile(k, r.buildContentFunc(k)); err == nil {
			result = append(result, file)
		}
	}

	return result, nil
}
Example #2
0
func (r *FileReader) Read() ([]*file.File, error) {
	ioFiles, err := ioutil.ReadDir(r.Path)
	if err != nil {
		return nil, err
	}

	files := make([]*file.File, 0)
	for _, ioFile := range ioFiles {
		if file, err := file.NewFile(ioFile.Name(), r.buildContentFunc(ioFile.Name())); err == nil {
			files = append(files, file)
		}
	}

	return files, nil
}