Hello! I am new to Pants, but have been looking in...
# general
a
Hello! I am new to Pants, but have been looking into it for a couple of days for use with a Go monorepo. So far it looks really great! ๐Ÿ™‚ One thing I always struggle with when trying out alternative build systems to native go modules is how to work with generated code, like Protobuf and such. You have a guide on Protobuf for Go, but it doesn't make sense to me how to make this work with tooling like
gopls
. As the generated files aren't written to disk as part of the project, there is no way for
gopls
to know about them. The guide says to run
pants export-codegen ::
to satisfy
go mod tidy
, but even this I don't get.
pants export-codegen ::
will export the files to
dist/codegen
, which will never be the import path in the go source files, so I don't get how this satisfies either
go mod tidy
or
gopls
. I feel like I am not understanding something. Anyone got any tips for me? ๐Ÿ˜„
In Bazel they created their own
GOPACKAGESDRIVER
, which you need to set up the editor with to replace go modules way of discovering packages. It wasn't a perfect solution though.
n
I ended up โ€œsolvingโ€ it by creating a symlink where Go expects the generated protobufs to be located that points to the relative path of the output of
export-codegen
. Pants is happy, Go and Go-related tools are happy, my IDE is happy, so good enough for me.
a
Yeah, that makes sense ๐Ÿ™‚
h
Yeah, Pants is currently (too?) opinionated about the fact that generated code shouldn't be in the source trees, that is useful feedback
๐Ÿ‘ 1