From 013ceb12bb82b871b54ca8a2dabe184ac534aa3c Mon Sep 17 00:00:00 2001 From: Richard Park Date: Sun, 19 May 2019 07:19:48 +0900 Subject: [PATCH] bug fix --- Gopkg.lock | 15 --------------- Gopkg.toml | 34 ---------------------------------- go.mod | 5 +++++ go.sum | 2 ++ registry/registry.go | 13 ++++++++++++- 5 files changed, 19 insertions(+), 50 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 50be962..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,15 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - branch = "master" - name = "git.loafle.net/commons/util-go" - packages = ["reflect"] - revision = "1966a985759721fd451171a78a0b8f4524afc644" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "a9ccea72cbcb32a9e2adaa190e9414c4d42e55920e7543a5d3a5db9f6c77b880" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 352e4a5..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,34 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[[constraint]] - branch = "master" - name = "git.loafle.net/commons/util-go" - -[prune] - go-tests = true - unused-packages = true diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..46160fd --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module git.loafle.net/commons/di-go + +go 1.12 + +require git.loafle.net/commons/util-go v0.0.0-20180823073240-bf5ffd1c385d diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7d1d0ca --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +git.loafle.net/commons/util-go v0.0.0-20180823073240-bf5ffd1c385d h1:OU8uK1BTFkWzsYJTP3Fc0P5c24mx3yTsRAkBZxQCFRU= +git.loafle.net/commons/util-go v0.0.0-20180823073240-bf5ffd1c385d/go.mod h1:/usq9jsy3wiGHPoYBPn+XGew2eqo+IFc5KYaR84x4Q0= diff --git a/registry/registry.go b/registry/registry.go index 92b023c..9ddf125 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -201,7 +201,18 @@ func (cr *defaultComponentRegistry) GetInstanceByName(name string) (interface{}, if ok { return v, nil } - return nil, fmt.Errorf("DI: Resource[%s] is not exist", name) + + td, ok := cr.definitionByName[name] + if !ok { + return nil, fmt.Errorf("DI: Instance[%s] is not exist", name) + } + + v, err := cr.GetInstance(td.Type) + if nil != err { + return nil, fmt.Errorf("DI: Instance[%s] is not exist -> %s", name, err.Error()) + } + + return v, nil } // GetInstances returns instance of annotated