MCPcopy Create free account
hub / github.com/basecamp/hey-cli / writeIDs

Method writeIDs

internal/output/writer.go:120–136  ·  view source on GitHub ↗
(data any)

Source from the content-addressed store, hash-verified

118// nil interface but neither a nil slice nor an interface holding a nil pointer, so an
119// empty listing would otherwise marshal as `"data": null` and the documented
120// `--jq '.data[]'` recipe would fail on it, and a mutation the API answered with
121// nothing would report `"data": null` rather than leaving the key out.
122func normalizeData(data any) any {
123 value := reflect.ValueOf(data)
124 switch {
125 case value.Kind() == reflect.Slice && value.IsNil():
126 return reflect.MakeSlice(value.Type(), 0, 0).Interface()
127 case value.Kind() == reflect.Pointer && value.IsNil():
128 return nil
129 default:
130 return data
131 }
132}
133
134func (w *Writer) Err(err error) {
135 e := apierr.AsError(err)
136 format := w.EffectiveFormat()
137
138 // An --html run is a person redirecting to a file: the error reads as text on
139 // stderr, as it does on a terminal, rather than as a JSON envelope. Either way the

Callers 1

OKMethod · 0.95

Calls 3

toSliceFunction · 0.85
ErrUsageFunction · 0.85
extractIDFunction · 0.85

Tested by

no test coverage detected