1
0
mirror of https://github.com/beego/bee.git synced 2024-11-15 03:20:54 +00:00
bee/parser/formatter.go

21 lines
448 B
Go
Raw Normal View History

2021-05-25 02:53:12 +00:00
package beeParser
import "encoding/json"
type AnnotationFormatter struct {
Annotation Annotator
}
func (f *AnnotationFormatter) Format(field *StructField) string {
if field.Comment == "" && field.Doc == "" {
return ""
}
kvs := f.Annotation.Annotate(field.Doc + field.Comment)
res, _ := json.Marshal(kvs)
return string(res)
}
func NewAnnotationFormatter() *AnnotationFormatter {
return &AnnotationFormatter{Annotation: &Annotation{}}
}