mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-21 03:05:43 +00:00
* chore: sync repo * release: 0.1.0-alpha.6 --------- Co-authored-by: Hanzo Dev <[email protected]>
30 lines
599 B
Go
30 lines
599 B
Go
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)
|
|
}
|