-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gen-accessors: skip Client struct and unexported fields #794
Conversation
Make gen-accessors.go skip certain struct and fields while creating accessor methods for structs and fields. Basically, now we have two more blacklists (blacklistStruct and blacklistField) respectively for blacklisted structs and fields. So, for every struct, it should first check and skip if the struct is in blacklist. Then, for every field, it should first check and skip if the struct is in blacklist.
682770b
to
60c9a1e
Compare
- Remove "service" from list of blacklisted fields because that was a mistake in the previous commit. - Add "service" to list of blacklisted structs because it would make more sense to not generate accessors for its fields. - Remove all debug printf statements.
60c9a1e
to
96efd17
Compare
github/gen-accessors.go
Outdated
// accessors. | ||
blacklistStruct = map[string]bool{ | ||
"Client": true, | ||
"service": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We never want to generate accessors for unexported types and fields, right?
Then I think we can/should simplify this. Instead of manually listing service
struct here, and client
field below, just add a general rule to skip unexported identifiers.
Then, blacklistStruct
will contain just Client
, and blacklistField
can go away completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah! Thanks for the hint. Made changes accordingly. Please review again.
9520cda
to
9eec6a7
Compare
Looks good so far, thanks @sahildua2305! I'll apply some comment formatting improvements and code simplifications, and then merge. |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks again!
…oogle#794) This change makes gen-accessors.go skip the following structs and fields from consideration when generating accessor methods: 1. Unexported structs and fields are skipped. They're unexported, and shouldn't have accessors. 2. Client struct is explicitly blacklistd and skipped. It was not meant to have accessors, and it doesn't need them. The generated accessors that are removed were added relatively recently, and it's not likely they were used since that time. Resolves google#778.
Make gen-accessors.go skip certain struct and fields while creating
accessor methods for structs and fields. Basically, now we have two more
blacklists (blacklistStruct and blacklistField) respectively for
blacklisted structs and fields.
So, for every struct, it should first check and skip if the struct
is in blacklist.
Then, for every field, it should first check and skip if the struct
is in blacklist.
Fixes #778