Skip to content
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

API client's should remove APIOptionsFunc type alias #144

Closed
jasdel opened this issue Aug 20, 2020 · 1 comment
Closed

API client's should remove APIOptionsFunc type alias #144

jasdel opened this issue Aug 20, 2020 · 1 comment

Comments

@jasdel
Copy link
Contributor

jasdel commented Aug 20, 2020

The type alias generated into API Client package, APIOptionsFunc should be removed because it makes it harder for utility functions defined outside of the API client's package to be compatible with the APIOptionsFunc type alias.

Type alias of a function doesn't really add any benefit other than documentation, since no additional methods will be added to the type alias.

func main() {
	var fn MyFunc

	fn = Impl
	fmt.Println(fn(&SomeType{}))

	SomeConfig(SomeSetup()...)
}

type MyFunc func(*SomeType) error

func Impl(t *SomeType) error {
	return nil
}

func SomeConfig(fns ...MyFunc) {

}

type SomeType struct{}

func SomeSetup() []func(*SomeType) error {

	return []func(*SomeType) error{}
}
cannot use SomeSetup() (type []func(*SomeType) error) as type []MyFunc in argument to SomeConfig

https://play.golang.org/p/754BI_LsS_6

@jasdel
Copy link
Contributor Author

jasdel commented Oct 12, 2020

type alise removed

@jasdel jasdel closed this as completed Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant