di/annotation/inject.go
crusader 700f188618 ing
2017-12-06 15:07:44 +09:00

34 lines
484 B
Go

package annotation
// @Inject(name? string)
import (
"fmt"
"reflect"
)
const (
InjectTag = "@Inject"
)
func init() {
registerAnnotation(InjectTag, reflect.TypeOf((*Inject)(nil)))
}
type Inject struct {
Annotation
Name string
}
func (a *Inject) parseAttribute(attributes map[string]string) error {
for k, v := range attributes {
switch k {
case "name":
a.Name = v
default:
return fmt.Errorf("Syntax error: not supported attribute[%s]", k)
}
}
return nil
}