andreykaipov / goobs

Go client library for OBS Studio
Apache License 2.0
129 stars 21 forks source link

fix: export Categories embedded struct #126

Closed ThisGuyCodes closed 9 months ago

ThisGuyCodes commented 9 months ago

I don't automatically assume this is wanted / will be accepted. But I figured the change was easy enough to make that the discussion could be started with the PR.

Embedding a private struct creates the confusing effect of exporting the public fields of the embedded struct without having them show in documentation.

This has some discussion at the language / godoc level: https://github.com/golang/go/issues/6600

This commit exports the subclients field of goobs.Client so the available fields show in documentation.

I actually used this project as an example for how this behavior of godoc is confusing for developers: https://github.com/golang/go/issues/6600#issuecomment-1874538749

andreykaipov commented 9 months ago

Woah that's interesting, I never noticed this! Crazy that issue goes back to 2013!

I'm definitely open to this. Since it'll now be exported though, what are your thoughts on renaming it to Categories? Shouldn't make it a difference since it's embedded, but on the off chance someone wants to use the full path I think client.Categories.General. reads a little nicer.

ThisGuyCodes commented 9 months ago

@andreykaipov absolutely! client.Subclients.General has an odd stutter to it now that you mention, and client.Categories.General feels much more communicative of how these subclients can be thought of.

It also seems that "category" will bring us closer to the nomenclature used in the OBS protocol itself? If I'm reading it correctly.

andreykaipov commented 9 months ago

It also seems that "category" will bring us closer to the nomenclature used in the OBS protocol itself? If I'm reading it correctly

Yup! I also refer to "category" in the generation code often because of that. I hope digging through that code wasn't too confusing btw. It's not really the prettiest! 😄 Thanks for your contribution!

andreykaipov commented 9 months ago

Docs looking sweet now 😎 https://pkg.go.dev/github.com/andreykaipov/goobs@v1.1.6#pkg-types

I really like it because now you can actually click from the main docs page to get to the pages for each category without having to look through the directories. I always felt like something was missing there. This was it!

Thanks again!