Hi. We have introduced Pants in our monorepo proje...
# general
a
Hi. We have introduced Pants in our monorepo project recently and it works fine with python, but we also have projects written in Go. We use go 1.18 with new feature Workspaces, so part of our internal libs are resolved in
workspace.go
, but not in
go.mod
Every lib has own
go.mod
. I have found this https://github.com/pantsbuild/pants/issues/13114#issuecomment-1185321565 comment and not sure, that I’m getting the point. Right now, I cannot build/run the service, because the
lib
is not found. I have tried with
Copy code
go_third_party_package(
    name="psykhe-common",
    import_path="go/lib/common",
)
but
go_third_party_package
is expected to be generated from
go.mod
file.
Note: for now, Pants only supports repositories using a single
go.mod
. Please comment on #13114 if you need support for greater than one
go.mod
so that we can prioritize adding support.
Does it mean that I cannot use pants for managing GO projects because I have more than 1
go.mod
file in the monorepo?
f
Correct, Pants only supports one
go_mod
target in a repository. It simplified the dependency inference feature back when bootstrapping the initial version of the backend. Easier to wait until someone actually needed the feature to then invest further work in the backend.
Also, Pants does not support the workspace feature of Go 1.18. I haven't even looked into how workspaces even function, so no triage on how hard it would be to support.
Multiple go.mod support would seem to be higher priority than workspaces in any event?
a
Yes, because we could use
replace
for internal libraries
f
(irony: The backend would also have to support
replace
in that case. Which I started to do a while back but would need to continue the work. https://github.com/tdyas/pants/tree/golang_handle_replace)
😢 1
As it turns out, it will probably be easier than I thought to support multiple go.mod's. I have a draft PR https://github.com/pantsbuild/pants/pull/16386 which allows me to have multiple go_mod targets inside my company's repository. Most of the support was already in Pants; I just had to fix dependency inference to understand the concept of multiple go_mod targets.
(and the PR still needs a lot of cleanup but at least there is a way forward)
The PR landed on
main
and was back-ported to the
2.14
branch (but has not been released yet, will be in next RC release).