Skip to content

Commit 8822b07

Browse files
committed
Merge pull request #17 from titanous/apply-tag
Make Apply play nice with other struct tags
2 parents 9aea7a2 + 73f95eb commit 8822b07

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

inject.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (inj *injector) Apply(val interface{}) error {
121121
for i := 0; i < v.NumField(); i++ {
122122
f := v.Field(i)
123123
structField := t.Field(i)
124-
if f.CanSet() && structField.Tag == "inject" {
124+
if f.CanSet() && (structField.Tag == "inject" || structField.Tag.Get("inject") != "") {
125125
ft := f.Type()
126126
v := inj.Get(ft)
127127
if !v.IsValid() {

inject_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type SpecialString interface {
1010
}
1111

1212
type TestStruct struct {
13-
Dep1 string `inject`
13+
Dep1 string `inject:"t" json:"-"`
1414
Dep2 SpecialString `inject`
1515
Dep3 string
1616
}

0 commit comments

Comments
 (0)