repositorypackage
0.9.0
Repository: https://github.com/manicar2093/goption.git
Documentation: pkg.go.dev
# README
Goption
A way to handle nil values.
Requirements
Use Go 1.18+ is a must. Goption uses Generics.
Description
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
SQL
You can use goption.Optional to sql package. Optional implements sql.Scanner and sql.Valuer
JSON Marshall
Unfortunately ,omitempty
is not supported by now due how json.Marshal works. For more details can see this link.