A way to handle nil values.
Use Go 1.18+ is a must. Goption uses Generics.
This is a copy of Java Optional. It contains almost all functions
- Empty
- Of
- Optional.Get
- Optional.IsPresent
- Optional.OrElseError
- Optional.OrElse
And others made specifically to go:
- Optional.MustGet
You can use goption.Optional to sql package. Optional implements sql.Scanner and sql.Valuer
Unfortunately ,omitempty
is not supported by now due how json.Marshal works. For more details can see this link.