MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / orEmpty

Function orEmpty

internal/httpapi/messages.go:709–714  ·  view source on GitHub ↗

orEmpty coalesces a nil slice of any element type to an empty slice so the JSON renders as [] rather than null (A-3). Pair with `nullable:"false"` on the field so the spec and the runtime agree.

(s []T)

Source from the content-addressed store, hash-verified

707// JSON renders as [] rather than null (A-3). Pair with `nullable:"false"` on
708// the field so the spec and the runtime agree.
709func orEmpty[T any](s []T) []T {
710 if s == nil {
711 return []T{}
712 }
713 return s
714}

Callers 2

handleExportUserDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected