-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.qtpl
57 lines (54 loc) · 1.43 KB
/
export.qtpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{% code
type jsonPackage struct {
Name string
Path string
Imported []string
ImportedBy []string
Funcs []string
Types []string
}
type jsonPackages struct {
Total int
Packages []jsonPackage
}
%}
// JSON marshaling
{% stripspace %}
{% func (d *jsonPackages) JSON() %}
{
"packages": [
{% for i, r := range d.Packages %}
{
"name": {%q= r.Name %},
"path": {%q= r.Path %},
"imported":[
{% for i, rr := range r.Imported %}
{%q= rr %}
{% if i + 1 < len(r.Imported) %},{% endif %}
{% endfor %}
],
"importedBy":[
{% for i, rr := range r.ImportedBy %}
{%q= rr %}
{% if i + 1 < len(r.ImportedBy) %},{% endif %}
{% endfor %}
],
"exported_funcs":[
{% for i, rr := range r.Funcs %}
{%q= rr %}
{% if i + 1 < len(r.Funcs) %},{% endif %}
{% endfor %}
],
"exported_types":[
{% for i, rr := range r.Types %}
{%q= rr %}
{% if i + 1 < len(r.Types) %},{% endif %}
{% endfor %}
],
}
{% if i + 1 < len(d.Packages) %},{% endif %}
{% endfor %}
]
}
{% endfunc %}
{% endstripspace %}