-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_gmfs_test.go
80 lines (70 loc) · 1.15 KB
/
example_gmfs_test.go
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package gmfs_test
import (
"bytes"
"os"
"regexp"
"github.com/Dokiys/gmfs"
)
func ExampleGenMsg() {
src := `
package example
import (
"strings"
"time"
)
func (i *Item) P() {}
// Item Comment 1
/*
Item Comment 1
*/
// Item Comment 1
type Item struct {
// Item ItemId Comment 3
// Item ItemId Comment 2
ItemId int // Item ItemId Comment 1
Name string
Duration time.Duration
CreatedAt time.Time
}
type TemplateData struct {
Arr []string
Items []*Item
Map1 map[string]*Item
// Unsupported
function func() bool
strings.Reader
}
`
r := bytes.NewReader([]byte(src))
exp, _ := regexp.Compile(".*")
_ = gmfs.GenMsg(r, os.Stdout, *exp)
// Output:
// // Item Comment 1
// /*
// Item Comment 1
// */
// // Item Comment 1
// message Item {
// // Item ItemId Comment 1
// int64 item_id = 1;
//
// string name = 2;
//
// Duration duration = 3;
//
// google.protobuf.Timestamp created_at = 4;
// }
//
// message TemplateData {
//
// repeated string arr = 1;
//
// repeated Item items = 2;
//
// map<string,Item> map1 = 3;
// // Unsupported
// // Unsupported field: function
//
// // Unsupported field: strings.Reader
// }
}