| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
An implementation of a Nullable type for JSON bodies, indicating whether the field is absent, set to null, or set to a value
Unlike other known implementations, this makes it possible to both marshal and unmarshal the value, as well as represent all three states:
And can be embedded in structs, for instance with the following definition:
obj := struct {
// RequiredID is a required, nullable field
RequiredID nullable.Nullable[int] `json:"id"`
// OptionalString is an optional, nullable field
// NOTE that no pointer is required, only `omitempty`
OptionalString nullable.Nullable[string] `json:"optionalString,omitempty"`
}{}Important
Although this project is under the oapi-codegen org for the oapi-codegen OpenAPI-to-Go code generator, this is intentionally released as a separate, standalone library which can be used by other projects.
First, add to your project with:
go get github.com/oapi-codegen/nullableCheck out the examples in the package documentation on pkg.go.dev for more details.
As well as contributions from:
Licensed under the Apache-2.0 license.
| Back | FazBrowse Home | New Git URL |