From 464345e796622453b1737ac1c24183d125117894 Mon Sep 17 00:00:00 2001 From: Milad Rahimi Date: Wed, 31 Mar 2021 15:43:35 +0430 Subject: [PATCH] add static methods --- container.go | 17 +++++++++++++++++ pkg/container/container_test.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/container.go b/container.go index b0b1c66..bcc048f 100644 --- a/container.go +++ b/container.go @@ -37,6 +37,23 @@ func Reset() { // It can take an abstraction (interface reference) and fill it with the related implementation. // It also can takes a function (receiver) with one or more arguments of the abstractions (interfaces) that need to be // resolved, Container will invoke the receiver function and pass the related implementations. +// Deprecated: Make is deprecated. func Make(receiver interface{}) error { return container.Make(receiver) } + +// Call takes a function with one or more arguments of the abstractions (interfaces) that need to be +// resolved, Container will invoke the receiver function and pass the related implementations. +func Call(receiver interface{}) error { + return container.Call(receiver) +} + +// Bind takes an abstraction (interface reference) and fill it with the related implementation. +func Bind(receiver interface{}) error { + return container.Bind(receiver) +} + +// Fill takes a struct and fills the fields with the tag `container:"inject"` +func Fill(receiver interface{}) error { + return container.Fill(receiver) +} diff --git a/pkg/container/container_test.go b/pkg/container/container_test.go index 5a70762..e3c8f24 100644 --- a/pkg/container/container_test.go +++ b/pkg/container/container_test.go @@ -295,7 +295,7 @@ func TestContainer_Fill_With_Struct_Pointer(t *testing.T) { assert.IsType(t, &MySQL{}, myApp.D) } -func TestContainer_FillUnexported_With_Struct_Pointer(t *testing.T) { +func TestContainer_Fill_Unexported_With_Struct_Pointer(t *testing.T) { err := instance.Singleton(func() Shape { return &Circle{a: 5} })