{"modulePath":"github.com/oapi-codegen/nullable","version":"v1.2.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package nullable\n\n## Types\n\n```go\ntype Nullable[T any] map[bool]T\n```\nNullable is a generic type, which implements a field that can be one of three states:\n\n\\- field is not set in the request - field is explicitly set to \\`null\\` in the request - field is explicitly set to a valid value in the request\n\nNullable is intended to be used with JSON marshalling and unmarshalling.\n\nInternal implementation details:\n\n\\- map\\[true]T means a value was provided - map\\[false]T means an explicit null was provided - nil or zero map means the field was not provided\n\nIf the field is expected to be optional, add the \\`omitempty\\` JSON tags. Do NOT use \\`\\*Nullable\\`!\n\nAdapted from [https://github.com/golang/go/issues/64515#issuecomment-1841057182](https://github.com/golang/go/issues/64515#issuecomment-1841057182)\n\n```go\nfunc NewNullNullable[T any]() Nullable[T]\n```\nNewNullNullable is a convenience helper to allow constructing a \\`Nullable\\` with an explicit \\`null\\`, for instance to construct a field inside a struct, without introducing an intermediate variable\n\n```go\nfunc NewNullableWithValue[T any](t T) Nullable[T]\n```\nNewNullableWithValue is a convenience helper to allow constructing a \\`Nullable\\` with a given value, for instance to construct a field inside a struct, without introducing an intermediate variable\n\n```go\nfunc (t Nullable[T]) Get() (T, error)\n```\nGet retrieves the underlying value, if present, and returns an error if the value was not present\n\n```go\nfunc (t Nullable[T]) GetOrEmpty() T\n```\nDig retrieves the underlying value or returns empty value if not present or was \\`null\\`. Use Get to distinguish between these cases.\n\n```go\nfunc (t Nullable[T]) IsNull() bool\n```\nIsNull indicate whether the field was sent, and had a value of \\`null\\`\n\n```go\nfunc (t Nullable[T]) IsSpecified() bool\n```\nIsSpecified indicates whether the field was sent\n\n```go\nfunc (t Nullable[T]) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (t Nullable[T]) MustGet() T\n```\n\n```go\nfunc (t *Nullable[T]) Set(value T)\n```\nSet sets the underlying value to a given value\n\n```go\nfunc (t *Nullable[T]) SetNull()\n```\nSetNull indicate that the field was sent, and had a value of \\`null\\`\n\n```go\nfunc (t *Nullable[T]) SetUnspecified()\n```\nSetUnspecified indicate whether the field was sent\n\n```go\nfunc (t *Nullable[T]) UnmarshalJSON(data []byte) error\n```\n\n","path":"github.com/oapi-codegen/nullable","name":"nullable","synopsis":"","isRedistributable":true}
