summaryrefslogtreecommitdiff
path: root/internal/util
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-11-20 12:22:28 +0000
committerLibravatar GitHub <noreply@github.com>2023-11-20 12:22:28 +0000
commit16275853eb8a43e0b113d476b896de53585c1281 (patch)
treeb2e0e6b4fc7cd4f1cc781e5c305ec24df38e6718 /internal/util
parent[chore]: Bump github.com/tdewolff/minify/v2 from 2.20.6 to 2.20.7 (#2370) (diff)
downloadgotosocial-16275853eb8a43e0b113d476b896de53585c1281.tar.xz
[bugfix] self-referencing collection pages for status replies (#2364)
Diffstat (limited to 'internal/util')
-rw-r--r--internal/util/ptr.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/util/ptr.go b/internal/util/ptr.go
index 2ce96e1d1..0ad207617 100644
--- a/internal/util/ptr.go
+++ b/internal/util/ptr.go
@@ -33,3 +33,11 @@ func EqualPtrs[T comparable](t1, t2 *T) bool {
func Ptr[T any](t T) *T {
return &t
}
+
+// PtrValueOr returns either value of ptr, or default.
+func PtrValueOr[T any](t *T, _default T) T {
+ if t != nil {
+ return *t
+ }
+ return _default
+}