While working on #770, I noticed that we are creating accessors only for fields which have a struct type. I looked further into it today and confirmed the same. Is this intentional? If so, why?
/cc @gmlewis @shurcooL
I'm not sure I understand what you mean.
https://github.com/google/go-github/blob/master/github/github-accessors.go#L24
returns a string, for example.
@sahildua2305 Can you give some examples of fields that are missing accessors?
For example - https://github.com/google/go-github/blob/8c08f4fba5e05e0fd2821a5f80cf0cf643bd5314/github/activity.go#L30
here - CurrentUserOrganizationURLs won't have any accessor because of the following logic -
https://github.com/google/go-github/blob/8c08f4fba5e05e0fd2821a5f80cf0cf643bd5314/github/gen-accessors.go#L103
The type of that particular field CurrentUserOrganizationURLs is []string. It鈥檚 not a pointer.
Not having an accessor for it seems reasonable, since the accessors exist for pointer fields to help prevent nil pointer dereference panics when a field is missing. Since there鈥檚 no pointer here, there鈥檚 nothing to protect against. The following code can never panic:
fmt.Println(len(feeds.CurrentUserOrganizationURLs))
Does that make sense? Or am I missing something? What would having an accessor for that field accomplish?
Oh right! Makes sense. I knew I was missing something. Thanks for clearing it out. 馃挴
Most helpful comment
The type of that particular field
CurrentUserOrganizationURLsis[]string. It鈥檚 not a pointer.Not having an accessor for it seems reasonable, since the accessors exist for pointer fields to help prevent
nilpointer dereference panics when a field is missing. Since there鈥檚 no pointer here, there鈥檚 nothing to protect against. The following code can never panic:Does that make sense? Or am I missing something? What would having an accessor for that field accomplish?