50
50
// this blacklist lists structs for which we don't want to generate
51
51
// accessors.
52
52
blacklistStruct = map [string ]bool {
53
- "Client" : true ,
54
- "service" : true ,
55
- }
56
- // this blacklist lists fields for which we don't want to generate
57
- // accessors.
58
- blacklistField = map [string ]bool {
59
- "client" : true ,
53
+ "Client" : true ,
60
54
}
61
55
)
62
56
@@ -107,6 +101,16 @@ func (t *templateData) processAST(f *ast.File) error {
107
101
if ! ok {
108
102
continue
109
103
}
104
+ // skip unexported identifiers
105
+ if ! ts .Name .IsExported () {
106
+ logf ("Struct %v is unexported; skipping." , ts .Name )
107
+ continue
108
+ }
109
+ // check in blacklist if the ts.Name struct is blacklisted
110
+ if key := fmt .Sprintf ("%v" , ts .Name ); blacklistStruct [key ] {
111
+ logf ("Struct %v blacklisted; skipping." , key )
112
+ continue
113
+ }
110
114
st , ok := ts .Type .(* ast.StructType )
111
115
if ! ok {
112
116
continue
@@ -118,14 +122,9 @@ func (t *templateData) processAST(f *ast.File) error {
118
122
}
119
123
120
124
fieldName := field .Names [0 ]
121
- // check in blacklist if the ts.Name struct is blacklisted
122
- if key := fmt .Sprintf ("%v" , ts .Name ); blacklistStruct [key ] {
123
- logf ("Struct %v blacklisted; skipping." , key )
124
- continue
125
- }
126
- // check in blacklist if the field is blacklisted
127
- if key := fmt .Sprintf ("%v" , fieldName ); blacklistField [key ] {
128
- logf ("Field %v is blacklisted; skipping." , key )
125
+ // skip unexported identifiers
126
+ if ! fieldName .IsExported () {
127
+ logf ("Field %v is unexported; skipping." , fieldName )
129
128
continue
130
129
}
131
130
// check for "struct.method" in blacklist
0 commit comments