-
-
Notifications
You must be signed in to change notification settings - Fork 112
Description
Rationale
since pact-go v2 was created, we rely on functionality from a rust shared core, which is delivered by way of C shared library, and is loaded via FFI (Foreign Function Interface) via cgo, into pact-go.
This has meant that users have to explicitly enable cgo, and those who cannot install or do have a c compiler installed, have been unable to use pact-go v2.
See #321 for a related issue.
Alternatives
- Rewrite pact-go in purego (not unfeasible, but highly undesired, and moves away from a single shared core mantra)
- Leverage ebitengine/purego - A library for calling C functions from Go without Cgo.
Leveraging ebitengine/purego
Options
- Utilise ebitengine/purego in CGO_ENABLED=0 mode only
- Retains standard cgo behaviour owned by the go team
- ebitengine/purego is in beta, so this uses a cautious approach
- Utilise ebitengine/purego in both CGO_ENABLED=0/CGO_ENABLED=1
- Consistent user experience in both modes,
- No need to maintain two sets of code CGO_ENABLED=0
- ebitengine/purego is in beta, so this uses a everything passes in CI approach (and we hope someone continues to maintain ebitengine/purego in the future)
End users experience
Currently users need to
- Ensure
CGO_ENABLED=1 - Ensure they have a CGO compiler
- Ensure they have installed the pact-go shared library
- Ensure the shared library is in an known place for CGO linking (hard coded in pact-go)
With ebitengine/purego, the user just needs to perform 3, and in step 4, they can point pact-go at wherever the shared library lives with no restrictions. This means it can be in non-standard paths, different versions could easily be managed.
Due to size reduces in the native libraries, we could possibly include the shared libraries in the code base. it would inflate the git history, but would make it very easy for uses to just plug and play with pact-go