gocloak icon indicating copy to clipboard operation
gocloak copied to clipboard

GoCloak is not an interface like documentation describe it

Open ymohl-cl opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

The go doc reference for gocloak package describe the client like a GoCloak interface. It seems to be a good approach to abstract the core Client.

The interface assume a succefull instantiate struct and a strong API Contract.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I'm always frustrated when i manipulate the core struct instance with the tentation for changing the internal fields.

Whats is the motivation to expose the struct instead of Interface ?

Describe the solution you'd like

The change to an interface cause an error inside the options parameters for the NewClient method. The solution should to have an internal type option.

I purpose you to make this rollback change.

i didn't find any resources about this topics ;)

ymohl-cl avatar Jul 26 '23 13:07 ymohl-cl

The change has been done to adhere to the accept interfaces, return structs principle.

https://github.com/golang/go/wiki/CodeReviewComments#interfaces https://dave.cheney.net/2016/08/20/solid-go-design https://mycodesmells.com/post/accept-interfaces-return-struct-in-go

Although yes, maybe the readme should be updated to not get people confused on this

MaxBreida avatar Aug 07 '23 17:08 MaxBreida

I think the interface should be part of the libary and can adhere to the principal. Checks should be made that the implemented struct methods satisfy the interface. This would make mocking, for testing pruposes, easier, by having an "offical" and up to date interface to mock against.

joshuai96 avatar Oct 11 '23 15:10 joshuai96

GoCloak being a struct breaks the accept interfaces, return structs principal. It requires passing GoCloak as a struct when using it.

WilSimpson avatar Mar 03 '24 18:03 WilSimpson