ReadFile reads and returns the content of the named file.
(name string)
| 329 | |
| 330 | // ReadFile reads and returns the content of the named file. |
| 331 | func (f FS) ReadFile(name string) ([]byte, error) { |
| 332 | file, err := f.Open(name) |
| 333 | if err != nil { |
| 334 | return nil, err |
| 335 | } |
| 336 | ofile, ok := file.(*openFile) |
| 337 | if !ok { |
| 338 | return nil, &fs.PathError{Op: "read", Path: name, Err: errors.New("is a directory")} |
| 339 | } |
| 340 | return []byte(ofile.f.data), nil |
| 341 | } |
| 342 | |
| 343 | // An openFile is a regular file open for reading. |
| 344 | type openFile struct { |
no test coverage detected