Hi team, I’ve been trying to set-up `pact-go` in ...
# pact-go
y
Hi team, I’ve been trying to set-up
pact-go
in a monorepo/bazel environment, since it depends on
pact_ffi
? 1. I saw PR attempts to bazelify pact-reference but it did not get much attention. 2. Another way I guess it might work is fetching the
.a
files as static library from releases like libpact_ffi-v0.4.1 using http_archive/http_file, and then linking them through go_library/clinkopts&cdeps. Is there an officially recommended way to do this?
m
there is no official way with Bazel I’m afraid, I don’t know much about it
thanks 1
y
Asking this question in a different way: In an automatic build system that you can’t pre-install stuff (such as bazel), to make pact-go work, you would need to download
pact_ffi
static library (i.e.,
<https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v0.4.1/libpact_ffi-osx-aarch64-apple-darwin.a.gz|libpact_ffi-osx-aarch64-apple-darwin.a.gz>
) and then tell cgo to link it properly. What would be the arguments to ask cgo to use this
.a
file when linking?
I saw cgo link opts are put here: https://github.com/pact-foundation/pact-go/blob/2.x.x/internal/native/lib.go The problem is how to override things like
/usr/local/lib -lpact_ffi
to make them point to the downloaded static library file.
m
That’s a good question. Does it need to be a static library or could you use the shared lib? Or is it because you’re expecting to run on heterogeneous OS environments that you want to link to the archive?
The problem is how to override things like
/usr/local/lib -lpact_ffi
to make them point to the downloaded static library file.
I wish those arguments could be dynamic, but it seems the way cgo wants to work is that they must be pre-defined in the source code. e.g. it would be nice to allow a user to put the library wherever they want, possibly defined by an env var. I tried several variations on this but never landed on a solution. If there is a way we can update the
lib.go
file to have locations that work for Bazel environments, i’d happily accept a PR.
y
It worked for me after removing the
/usr/local/lib
part for me. Yeah bazel support patching build files to override what you defined in
lib.go
so no need for a PR here. Thanks!
🙌 1
m
Awesome, thanks! Is there any lessons we can take to update our docs? Feel free to suggest via a PR or GH issue to scratch out any thoughts. Glad to hear it’s working though!
y
I’m just getting started on trying pact out. It’s just 1st step (getting pact build in monorepo/bazel env). I can probably come back and share something if I end up having the test flow running e2e.
👍 1