From 663d3be15312e0d6a78e170a14efaded553f5b8b Mon Sep 17 00:00:00 2001 From: Sven Walter Date: Thu, 19 Dec 2024 12:55:57 +0100 Subject: [PATCH] add digutil --- pkg/digutil/types.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pkg/digutil/types.go diff --git a/pkg/digutil/types.go b/pkg/digutil/types.go new file mode 100644 index 0000000..002772f --- /dev/null +++ b/pkg/digutil/types.go @@ -0,0 +1,14 @@ +package digutil + +import "go.uber.org/dig" + +type Optional[T any] struct { + dig.In + Value *T `optional:"true"` +} + +func ProvideValue[T any](c *dig.Container, v T) error { + return c.Provide(func() T { + return v + }) +}