Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateAnnotationValue(a *AnnotatedEntry, packageName string, foundImports []string) (string, []string)
- func GenerateRegistry(path, pck, outName string)
- func GetFieldAnnotations(s interface{}, fieldName string) []interface{}
- func GetFuncAnnotation(s interface{}) []interface{}
- func GetMethodAnnotations(s interface{}, methodName string) []interface{}
- func GetStructAnnotations(s interface{}) []interface{}
- func Map(s string, a Annotations)
- func MapType(i interface{}, a Annotations)
- type AnnotatedEntry
- type AnnotationDoc
- type Annotations
- type AnnotationsData
Constants ¶
const (
DEFAULT_PARAM = "&"
)
Variables ¶
var (
ROOTS = filepath.SplitList(os.Getenv("GOPATH"))
)
Functions ¶
func GenerateAnnotationValue ¶
func GenerateAnnotationValue(a *AnnotatedEntry, packageName string, foundImports []string) (string, []string)
Returns annotated entry annotations descriptor and list of all annotations packages in it Parameters: - annotated entry - full package name - list of imports in the entry source
func GenerateRegistry ¶
func GenerateRegistry(path, pck, outName string)
Generates the code for register a set of annotations within provided package. Parameters: - path - the folder where package source files are located; - pck - the shoirt package name; - outName - name of output source file; if it is empty then <package>_annotations.go will be used
func GetFieldAnnotations ¶
func GetFieldAnnotations(s interface{}, fieldName string) []interface{}
Returns annotations bundle for specified field of provided object type. Object instance or its reflect.Type is passed as the first parameter. Field name is passed as the second parameter. If no annotation defined for given type or specified field is not annotated or no such field exist then nil is returned
func GetFuncAnnotation ¶
func GetFuncAnnotation(s interface{}) []interface{}
Returns annotations bundle for provided func type. Func instance or its reflect.Type is passed as the parameter. If no annotation defined for given type then nil is returned
func GetMethodAnnotations ¶
func GetMethodAnnotations(s interface{}, methodName string) []interface{}
Returns annotations bundle for specified method of provided object type. Object instance or its reflect.Type is passed as the first parameter. Method name is passed as the second parameter. If no annotation defined for given type then nil is returned
func GetStructAnnotations ¶
func GetStructAnnotations(s interface{}) []interface{}
Returns annotations bundle for provided struct type. Object instance or its reflect.Type is passed as the parameter. If no annotation defined for given type then nil is returned
func Map ¶
func Map(s string, a Annotations)
Maps annotations bundle to provided string. Usually string contains the type and the name of annotated entry
func MapType ¶
func MapType(i interface{}, a Annotations)
Maps annotation bundle to the type and name of provided object
Types ¶
type AnnotatedEntry ¶
type AnnotatedEntry struct { Type string // type name of annotated entry of func/method name FullPackage string // full package name of annotated entry Name string // the name of annotated struct/func/interface/method AnnotationsData // related annotation data }
Full description of annotated entry
type AnnotationDoc ¶
Annotation properties extracted from the comments
func FindAnnotations ¶
func FindAnnotations(doc string) []AnnotationDoc
Returns objects for all found annotations in provided comment Objects contain only the map of attribute names and associated values
type Annotations ¶
type Annotations struct { Self []interface{} Fields map[string][]interface{} Methods map[string][]interface{} }
The annotations bundle stored in Registry for each entry. It is automatically generated and consists of structs representing custom annotations
type AnnotationsData ¶
type AnnotationsData struct { Self []AnnotationDoc // annotations related to struct/func/interface name Fields map[string][]AnnotationDoc // annotations related to struct field Methods map[string][]AnnotationDoc // annotations related to struct methods }
Bundle of annotations related to object in source code