From 50c247a210a4dd3014d20c9489836e2b0a2bbabe Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Thu, 18 Sep 2025 18:14:30 -0700 Subject: [PATCH] allow checking if a Provide is Nil --- di.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/di.go b/di.go index 43607ff817d2568005e70334df48b07f644d5f27..2aa1d5b3b8e82ce1427931ca35dfc059a353f2fb 100644 --- a/di.go +++ b/di.go @@ -38,6 +38,7 @@ import ( type Provide[Out any] struct { fOrV any set bool + Nil bool } // Optional is the canonical way of specifying a field is optional. The library @@ -99,6 +100,7 @@ func NewProvide[Out any](ctorOrVal any) (Provide[Out], error) { if ctorOrVal == nil { if canBeNil(outType) { + out.Nil = true return out, nil } return zero, fmt.Errorf("Provide[%v]: nil not valid for non-nilable type", outType)