di/annotation/resource.go
crusader 4a4e7cdfdd ing
2017-12-05 22:28:42 +09:00

36 lines
467 B
Go

package annotation
import "strings"
const (
ResourceTag = "@Resource"
)
type Resource struct {
Annotation
Name string
}
func ParseResource(a string) (*Resource, error) {
i := strings.Index(a, ResourceTag)
if -1 == i {
return nil, nil
}
inject := &Resource{}
atts, err := ParseAttribute(a, i+len(ResourceTag))
if nil != err {
return nil, err
}
for k, v := range atts {
switch k {
case "name":
inject.Name = v
}
}
return inject, nil
}