+1
-4
json2go.go
+1
-4
json2go.go
···
24
24
return &Transformer{}
25
25
}
26
26
27
-
// Transform ...
28
-
// todo: take io.Reader as input?
29
-
// todo: output as io.Writer?
27
+
// Transform transforms provided json string into go type annotation
30
28
func (t *Transformer) Transform(structName, jsonStr string) (string, error) {
31
29
if !identRe.MatchString(structName) {
32
30
return "", ErrInvalidStructName
···
89
87
fieldType := t.getGoType(fieldName, f.type_)
90
88
t.currentIndent--
91
89
92
-
// todo: toggle json tags generation
93
90
jsonTag := fmt.Sprintf("`json:\"%s\"`", f.field)
94
91
95
92
indent := strings.Repeat("\t", t.currentIndent+1)