mirror of
https://github.com/openai/openai-go.git
synced 2026-04-01 17:17:14 +09:00
20 lines
765 B
Go
20 lines
765 B
Go
package param
|
|
|
|
import "github.com/openai/openai-go/v3/internal/encoding/json/sentinel"
|
|
|
|
// NullMap returns a non-nil map with a length of 0.
|
|
// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
|
|
//
|
|
// It is unspecified behavior to mutate the map returned by [NullMap].
|
|
func NullMap[MapT ~map[string]T, T any]() MapT {
|
|
return sentinel.NewNullSentinel(func() MapT { return make(MapT, 1) })
|
|
}
|
|
|
|
// NullSlice returns a non-nil slice with a length of 0.
|
|
// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
|
|
//
|
|
// It is unspecified behavior to mutate the slice returned by [NullSlice].
|
|
func NullSlice[SliceT ~[]T, T any]() SliceT {
|
|
return sentinel.NewNullSentinel(func() SliceT { return make(SliceT, 0, 1) })
|
|
}
|