Releases: lucas-masiero/optional
Optional-V2
Optional
The optional
package is a powerful and flexible solution for handling optional values in Go. It provides the Option
type, allowing you to elegantly handle scenarios where a value may or may not be present.
With Option
, you can easily represent both the presence and absence of a value without resorting to null pointers or custom error handling. This package promotes cleaner code by encapsulating optional values within a standardized type, enabling safer and more expressive programming.
Key Features:
- Create optional values using the
Some
andNone
functions. - Check if an optional value is present using the
IsSome
method. - Retrieve the inner value of a
Some
optional value using theUnwrap
method. - Seamless integration with JSON marshalling and unmarshalling.
- Simplify error handling when dealing with optional values.
By utilizing the optional
package, you can enhance the readability and maintainability of your Go code, making it more robust and less prone to errors.
Please refer to the provided documentation and examples for a detailed understanding of the package and its usage.
Updates
- Refactor on Tests for Unmarshal (added new tests for some missing types)
- Refactor on Tests for Marshal (added new tests for some missing types with table testing)
Optional
Optional
The optional
package is a powerful and flexible solution for handling optional values in Go. It provides the Option
type, allowing you to elegantly handle scenarios where a value may or may not be present.
With Option
, you can easily represent both the presence and absence of a value without resorting to null pointers or custom error handling. This package promotes cleaner code by encapsulating optional values within a standardized type, enabling safer and more expressive programming.
Key Features:
- Create optional values using the
Some
andNone
functions. - Check if an optional value is present using the
IsSome
method. - Retrieve the inner value of a
Some
optional value using theUnwrap
method. - Seamless integration with JSON marshalling and unmarshalling.
- Simplify error handling when dealing with optional values.
By utilizing the optional
package, you can enhance the readability and maintainability of your Go code, making it more robust and less prone to errors.
Please refer to the provided documentation and examples for a detailed understanding of the package and its usage.