Skip to content

Commit

Permalink
gen-accessors: skip unexported field or structs
Browse files Browse the repository at this point in the history
  • Loading branch information
sahildua2305 committed Nov 25, 2017
1 parent 96efd17 commit 9eec6a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 199 deletions.
29 changes: 14 additions & 15 deletions github/gen-accessors.go
Expand Up @@ -50,13 +50,7 @@ var (
// this blacklist lists structs for which we don't want to generate
// accessors.
blacklistStruct = map[string]bool{
"Client": true,
"service": true,
}
// this blacklist lists fields for which we don't want to generate
// accessors.
blacklistField = map[string]bool{
"client": true,
"Client": true,
}
)

Expand Down Expand Up @@ -107,6 +101,16 @@ func (t *templateData) processAST(f *ast.File) error {
if !ok {
continue
}
// skip unexported identifiers
if !ts.Name.IsExported() {
logf("Struct %v is unexported; skipping.", ts.Name)
continue
}
// check in blacklist if the ts.Name struct is blacklisted
if key := fmt.Sprintf("%v", ts.Name); blacklistStruct[key] {
logf("Struct %v blacklisted; skipping.", key)
continue
}
st, ok := ts.Type.(*ast.StructType)
if !ok {
continue
Expand All @@ -118,14 +122,9 @@ func (t *templateData) processAST(f *ast.File) error {
}

fieldName := field.Names[0]
// check in blacklist if the ts.Name struct is blacklisted
if key := fmt.Sprintf("%v", ts.Name); blacklistStruct[key] {
logf("Struct %v blacklisted; skipping.", key)
continue
}
// check in blacklist if the field is blacklisted
if key := fmt.Sprintf("%v", fieldName); blacklistField[key] {
logf("Field %v is blacklisted; skipping.", key)
// skip unexported identifiers
if !fieldName.IsExported() {
logf("Field %v is unexported; skipping.", fieldName)
continue
}
// check for "struct.method" in blacklist
Expand Down
184 changes: 0 additions & 184 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9eec6a7

Please sign in to comment.