Skip to content

Commit 931c976

Browse files
chore(internal): codegen related update
1 parent fdd8fa6 commit 931c976

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

internal/paramutil/sentinel.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package paramutil
2+
3+
import (
4+
"github.com/anthropics/anthropic-sdk-go/internal/encoding/json/sentinel"
5+
)
6+
7+
// NullPtr returns a pointer to the zero value of the type T.
8+
// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
9+
//
10+
// It is unspecified behavior to mutate the value pointed to by the returned pointer.
11+
func NullPtr[T any]() *T {
12+
return sentinel.NullPtr[T]()
13+
}
14+
15+
// IsNullPtr returns true if the pointer was created by [NullPtr].
16+
func IsNullPtr[T any](ptr *T) bool {
17+
return sentinel.IsNullPtr(ptr)
18+
}
19+
20+
// NullSlice returns a non-nil slice with a length of 0.
21+
// When used with [MarshalObject] or [MarshalUnion], it will be marshaled as null.
22+
//
23+
// It is undefined behavior to mutate the slice returned by [NullSlice].
24+
func NullSlice[T any]() []T {
25+
return sentinel.NullSlice[T]()
26+
}
27+
28+
// IsNullSlice returns true if the slice was created by [NullSlice].
29+
func IsNullSlice[T any](slice []T) bool {
30+
return sentinel.IsNullSlice(slice)
31+
}

0 commit comments

Comments
 (0)