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

40 lines
482 B
Go

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