pact-foundation / pact-go

Golang version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
http://pact.io
MIT License
828 stars 103 forks source link

Why is there a functional pattern constructore for the installer? #381

Closed becheran closed 3 months ago

becheran commented 3 months ago

https://github.com/pact-foundation/pact-go/blob/83d7e0c8742848a2b19bbcf3c9e74f3ea79a36b2/installer/installer.go#L43

I was a bit puzzeled when I first saw the function signature. I am quite familiar with the options pattern. But I have no idea how I am supposed to use this here? Was this commited by accident?

Because as a user of the library I don't have any options to set. I need to use the setter methods anyways. Such as SetLibDir(string).

Was it somehow thought to be used in the future or was it simply forgotten to be deleted?

mefellows commented 3 months ago

Yeah, it's a good question. I definitely can't remember why it was done that way, but I can see how it could be useful for an internal package. It's plausible it was initially not meant to be part of the public API.

One likely time it deviated was when I discovered that I couldn't have any CGO dependencies alongside the installer package (anything that depends on the native code by definition needs the C library to be loaded, so you can't also have code in that package that checks that it's loaded, what version it is etc.).

So a refactor may have happened which essentially made a version of this redundant. As it's in the public API now I can't remove it.

I'll close it for now, but we can re-open if there are suggestions to improve it.