MCPcopy Create free account
hub / github.com/cli/cli / appendJSONL

Function appendJSONL

script/ghmock/store.go:224–237  ·  view source on GitHub ↗

appendJSONL adds items to a file, one JSON object per line.

(path string, items []T)

Source from the content-addressed store, hash-verified

222
223// appendJSONL adds items to a file, one JSON object per line.
224func appendJSONL[T any](path string, items []T) error {
225 if len(items) == 0 {
226 return nil
227 }
228 f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644)
229 if err != nil {
230 return err
231 }
232 if err := writeJSONL(f, items); err != nil {
233 f.Close()
234 return err
235 }
236 return f.Close()
237}
238
239func writeJSONL[T any](w io.Writer, items []T) error {
240 enc := json.NewEncoder(w)

Callers 4

appendLogMethod · 0.85
appendRunMethod · 0.85
cmdGitSSHFunction · 0.85
cmdGitFunction · 0.85

Calls 2

writeJSONLFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected