MCPcopy
hub / github.com/larksuite/cli / ReadInputFile

Function ReadInputFile

internal/cmdutil/resolve.go:80–94  ·  view source on GitHub ↗

ReadInputFile reads path through fileIO. Open/read failures are wrapped with path context; fileio.ErrPathValidation remains matchable with errors.Is.

(fileIO fileio.FileIO, path string)

Source from the content-addressed store, hash-verified

78// ReadInputFile reads path through fileIO. Open/read failures are wrapped with
79// path context; fileio.ErrPathValidation remains matchable with errors.Is.
80func ReadInputFile(fileIO fileio.FileIO, path string) ([]byte, error) {
81 if fileIO == nil {
82 return nil, fmt.Errorf("file input is not available in this context")
83 }
84 f, err := fileIO.Open(path)
85 if err != nil {
86 return nil, wrapInputFileError(path, err)
87 }
88 defer f.Close()
89 data, err := io.ReadAll(f)
90 if err != nil {
91 return nil, wrapInputFileError(path, err)
92 }
93 return data, nil
94}
95
96func wrapInputFileError(path string, err error) error {
97 if errors.Is(err, fileio.ErrPathValidation) {

Callers 7

apps_db_execute.goFile · 0.92
resolveExecuteSQLFunction · 0.92
resolveInputFlagsFunction · 0.92
readHTML5BlockPathFunction · 0.92
ResolveInputFunction · 0.85

Calls 3

wrapInputFileErrorFunction · 0.85
OpenMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected