Overview
The Gcore Go SDK uses theomitzero semantics from the Go 1.24+ encoding/json release for request fields.
Required Fields
Required primitive fields (int64, string, etc.) feature the tag `json:”…,required”`. These fields are always serialized, even their zero values.
Optional Fields
Optional primitive types are wrapped in aparam.Opt[T]. These fields can be set with the provided constructors:
gcore.String(string)gcore.Int(int64)- And similar constructors for other types
param.Opt[T], map, slice, struct or string enum uses the tag `json:”…,omitzero”`. Its zero value is considered omitted.
The param.IsOmitted(any) function can confirm the presence of any omitzero field.
Basic Example
Sending Null Values
Use
param.Null[T]() for optional fields and param.NullStruct[T]() for struct fields when you need to explicitly send null.null instead of a param.Opt[T], use param.Null[T]().
To send null instead of a struct T, use param.NullStruct[T]().
Extra Fields
Request structs contain a.SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key.
Custom Values with Override
To send a custom value instead of a struct, useparam.Override[T](value).
