summaryrefslogtreecommitdiff
path: root/pkg/pls
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-30 12:23:57 -0600
committermo khan <mo@mokhan.ca>2025-04-30 12:23:57 -0600
commit85b49396ce10aef9214803c5cfdf5c1d5cb93af9 (patch)
tree301969c71e400a43c99f2fc27f06b1f7574b791d /pkg/pls
parentea841ab274630cff287a586d9799663a28c708fc (diff)
refactor: extract generic function to create and initialize any type
Diffstat (limited to 'pkg/pls')
-rw-r--r--pkg/pls/option.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/pls/option.go b/pkg/pls/option.go
index bd717fa..fae002c 100644
--- a/pkg/pls/option.go
+++ b/pkg/pls/option.go
@@ -1,3 +1,13 @@
package pls
+import "github.com/xlgmokha/x/pkg/x"
+
type Option[T any] func(T) T
+
+func New[T any](options ...Option[T]) T {
+ item := x.Default[T]()
+ for _, option := range options {
+ item = option(item)
+ }
+ return item
+}