MCPcopy Create free account
hub / github.com/crawshaw/jsonfile / New

Function New

jsonfile.go:28–34  ·  view source on GitHub ↗

New creates a new empty JSONFile at the given path.

(path string)

Source from the content-addressed store, hash-verified

26
27// New creates a new empty JSONFile at the given path.
28func New[Data any](path string) (*JSONFile[Data], error) {
29 p := &JSONFile[Data]{path: path, bytes: []byte("{}"), data: new(Data)}
30 if err := p.Write(func(*Data) error { return nil }); err != nil {
31 return nil, fmt.Errorf("jsonfile.New: %w", err)
32 }
33 return p, nil
34}
35
36// Load loads an existing JSONFileData from the given path.
37//

Callers

nothing calls this directly

Calls 1

WriteMethod · 0.95

Tested by

no test coverage detected