openai/openai-go

Public

mirrored fromhttps://github.com/openai/openai-goAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9314b6c3bd913e265f75d0a49600b60d6d25d8ae

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

packages/param/null.go

19lines · modecode

1package param
2
3import "github.com/openai/openai-go/v3/internal/encoding/json/sentinel"
4
5// NullMap returns a non-nil map with a length of 0.
6// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
7//
8// It is unspecified behavior to mutate the map returned by [NullMap].
9func NullMap[MapT ~map[string]T, T any]() MapT {
10 return sentinel.NewNullSentinel(func() MapT { return make(MapT, 1) })
11}
12
13// NullSlice returns a non-nil slice with a length of 0.
14// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
15//
16// It is unspecified behavior to mutate the slice returned by [NullSlice].
17func NullSlice[SliceT ~[]T, T any]() SliceT {
18 return sentinel.NewNullSentinel(func() SliceT { return make(SliceT, 0, 1) })
19}
20