aboutsummaryrefslogtreecommitdiff
path: root/option/option.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-05-03 20:16:14 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-05-03 20:16:14 +0200
commit80e08e6aee59ef32355fe5a376f295f1fd7dec1c (patch)
treeb49c2f974a9898caa3dd9cb094101a1b236c0e32 /option/option.go
parent9fd5ae1214c3f4af53dfa5c45adee68769981b18 (diff)
downloadgo-gg-80e08e6aee59ef32355fe5a376f295f1fd7dec1c.tar.gz
change module path to go.xyrillian.de/gg
Also, some other small adjustments for the documentation to make it fit with the overall vibe of the new home.
Diffstat (limited to 'option/option.go')
-rw-r--r--option/option.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/option/option.go b/option/option.go
index a96e87d..8bd614c 100644
--- a/option/option.go
+++ b/option/option.go
@@ -106,7 +106,7 @@
//
// dbURL := GetDatabaseURLFromEnvironment().UnwrapOrPanic("no DB connection found")
// // ^ This is a much clearer phrasing.
-package option
+package option // import "go.xyrillian.de/gg/option"
import (
"database/sql"
@@ -173,6 +173,8 @@ func (o Option[T]) AsSlice() []T {
}
// Filter removes the contained value (if any) from the Option if it does not match the predicate.
+//
+// See package go.xyrillian.de/gg/is for pre-made predicates.
func (o Option[T]) Filter(predicate func(T) bool) Option[T] {
if o.isSome && predicate(o.value) {
return o
@@ -194,6 +196,8 @@ func (o Option[T]) IsSome() bool {
}
// IsSomeAnd returns whether the Option contains a value that matches the given predicate.
+//
+// See package go.xyrillian.de/gg/is for pre-made predicates.
func (o Option[T]) IsSomeAnd(predicate func(T) bool) bool {
return o.isSome && predicate(o.value)
}
@@ -201,6 +205,8 @@ func (o Option[T]) IsSomeAnd(predicate func(T) bool) bool {
// IsNoneOr returns whether the Option is either empty, or contains a value that matches the given predicate.
//
// If the predicate compares against the zero value, use options.IsNoneOrZero() instead.
+//
+// See package go.xyrillian.de/gg/is for pre-made predicates.
func (o Option[T]) IsNoneOr(predicate func(T) bool) bool {
return !o.isSome || predicate(o.value)
}