Skip to content

gen-accessors should skip Client, service structs and unexported fields. #778

Closed
@dmitshur

Description

@dmitshur

There are two issues with gen-accessors.go generating accessors it should not be (/cc @gmlewis FYI). It's relatively harmless, but should be fixed.

First, gen-accessors.go does not skip unexported fields, which causes it to generate accessors that it shouldn't. For example:

// Getclient returns the client field.
func (s *service) Getclient() *Client {
	if s == nil {
		return nil
	}
	return s.client
}

Second, it does not skip certain structs that it should skip, including Client, service, and perhaps others. It should only generate accessors for structs that are mapped to GitHub objects. For example:

image

image

Activity

sahildua2305

sahildua2305 commented on Nov 14, 2017

@sahildua2305
Member

@shurcooL I'd like to tackle this. What do you think about having an extended list of blacklisted structs to avoid while generating accessor methods?

dmitshur

dmitshur commented on Nov 15, 2017

@dmitshur
MemberAuthor

Thanks!

I think adding a list of blacklisted structs is the way to go. There's only a couple of them.

added a commit that references this issue on Dec 2, 2017
fbfee05
added a commit that references this issue on May 1, 2018
21d7519
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @dmitshur@sahildua2305

      Issue actions

        gen-accessors should skip Client, service structs and unexported fields. · Issue #778 · google/go-github