add close method
close Calls the close method on all singleton instances within the container.
Do you believe it's truly the responsibility of the IOC container to handle the closure of services?
Do you believe it's truly the responsibility of the IOC container to handle the closure of services?
I tried to close all instances with Close(c container.Container), but concrete.isSingleton and concrete.make are unexported fields and methods.
Thanks for your help!
I think it is necessary to condition the close method.
- have no impact on existing functions and methods
- Convenient to close db like services
I know that close is not a special method, and I don't understand why all objects should have such a method. Could you explain more about it?
I know that close is not a special method, and I don't understand why all objects should have such a method. Could you explain more about it?
Although 'close' is not a special method, some objects conventionally use it to release resources such as databases or files.
Therefore, if the Singleton has a 'close' method, it should be called to release the resource.
v := reflect.ValueOf(instance)
mm := v.MethodByName("Close")
if mm.IsValid() {}