(pathElements ...string)
| 26 | } |
| 27 | |
| 28 | func (f fsFetcher) File(pathElements ...string) ([]byte, error) { |
| 29 | if len(pathElements) == 0 { |
| 30 | return nil, errFilenameNotSpecified.New() |
| 31 | } |
| 32 | |
| 33 | start := time.Now() |
| 34 | |
| 35 | p := filepath.Join(pathElements...) |
| 36 | rp, err := realOSPath(f.root, p) |
| 37 | if err != nil { |
| 38 | return nil, err |
| 39 | } |
| 40 | content, err := os.ReadFile(rp) |
| 41 | if err == nil { |
| 42 | f.observeLatency(time.Since(start)) |
| 43 | return content, nil |
| 44 | } |
| 45 | |
| 46 | if os.IsNotExist(err) { |
| 47 | return nil, errFileNotFound.WithAttributes("filename", p) |
| 48 | } |
| 49 | return nil, errCouldNotReadFile.WithCause(err).WithAttributes("filename", p) |
| 50 | } |
| 51 | |
| 52 | // FromFilesystem returns an interface that fetches files from the local filesystem. |
| 53 | func FromFilesystem(rootElements ...string) Interface { |
nothing calls this directly
no test coverage detected