summaryrefslogtreecommitdiffhomepage
path: root/packages/sdk/go/internal/param
diff options
context:
space:
mode:
authorDax <[email protected]>2025-07-31 01:00:29 -0400
committerGitHub <[email protected]>2025-07-31 01:00:29 -0400
commit33cef075d228e80aefb44671ec68e1989c2855a8 (patch)
treed43a5c1bcc40d4d938eacccfd923c80301706cf1 /packages/sdk/go/internal/param
parentb09ebf464552f3899120b22c7a8572669000a554 (diff)
downloadopencode-33cef075d228e80aefb44671ec68e1989c2855a8.tar.gz
opencode-33cef075d228e80aefb44671ec68e1989c2855a8.zip
ci: new publish method (#1451)
Diffstat (limited to 'packages/sdk/go/internal/param')
-rw-r--r--packages/sdk/go/internal/param/field.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/sdk/go/internal/param/field.go b/packages/sdk/go/internal/param/field.go
new file mode 100644
index 000000000..4d0fd9c6f
--- /dev/null
+++ b/packages/sdk/go/internal/param/field.go
@@ -0,0 +1,29 @@
+package param
+
+import (
+ "fmt"
+)
+
+type FieldLike interface{ field() }
+
+// Field is a wrapper used for all values sent to the API,
+// to distinguish zero values from null or omitted fields.
+//
+// It also allows sending arbitrary deserializable values.
+//
+// To instantiate a Field, use the helpers exported from
+// the package root: `F()`, `Null()`, `Raw()`, etc.
+type Field[T any] struct {
+ FieldLike
+ Value T
+ Null bool
+ Present bool
+ Raw any
+}
+
+func (f Field[T]) String() string {
+ if s, ok := any(f.Value).(fmt.Stringer); ok {
+ return s.String()
+ }
+ return fmt.Sprintf("%v", f.Value)
+}