MCPcopy Create free account
hub / github.com/nhost/nhost / readFile

Function readFile

cli/cmd/config/edit.go:84–102  ·  view source on GitHub ↗
(filepath string)

Source from the content-addressed store, hash-verified

82}
83
84func readFile(filepath string) (any, error) {
85 f, err := os.Open(filepath)
86 if err != nil {
87 return nil, fmt.Errorf("failed to open file: %w", err)
88 }
89 defer f.Close()
90
91 b, err := io.ReadAll(f)
92 if err != nil {
93 return nil, fmt.Errorf("failed to read file: %w", err)
94 }
95
96 var v any
97 if err := toml.Unmarshal(b, &v); err != nil {
98 return nil, fmt.Errorf("failed to unmarshal toml: %w", err)
99 }
100
101 return v, nil
102}
103
104func GenerateJSONPatch(origfilepath, newfilepath, dst string) error {
105 origo, err := readFile(origfilepath)

Callers 2

GenerateJSONPatchFunction · 0.70
FromYAMLFunction · 0.50

Calls 2

ErrorfMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected