Skip to content

fix: go mod vendor #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 3, 2025
Merged

fix: go mod vendor #131

merged 3 commits into from
Apr 3, 2025

Conversation

cmgsj
Copy link
Contributor

@cmgsj cmgsj commented Feb 11, 2025

Fixes #61

Inspired by:

Changes:

  • Generate gokeep.go files to (like .gitkeep) to force Go tooling to keep non-Go (.c and .h) files when vendoring.
  • Generate parser/build_cgo.go file importing all gokeep packages.
  • Make the above steps reproducible by running scripts/gokeep.sh on make update_source.

@lfittl
Copy link
Member

lfittl commented Feb 11, 2025

Thanks for the contribution! - I'm definitely open to making this work, so we can drop the extra effort with vendoring the library.

Make update_source reproducible using git patch gokeep.patch.

I don't think that's the right approach, since Postgres major releases will bring different include folders, and so we'd have to update that patch each time.

What if instead we came up with a list of all include directories (through bash scripting) and then auto-generated the relevant keep files during the extract source step?

We could have each of the nested files use this template:

//go:build required
// +build required

// package gokeep prevents go tooling from stripping the c dependencies.
package gokeep

And then only have the list of imports at the top-level build_cgo.go file (which would take a string substitution of the list of nested files to be imported).

Do you want to adjust the PR to work like that?

@cmgsj
Copy link
Contributor Author

cmgsj commented Feb 11, 2025

//go:build required
// +build required

// package gokeep prevents go tooling from stripping the c dependencies.
package gokeep

Yeah, that makes sense, I'll update my PR. Thanks!

Copy link
Member

@lfittl lfittl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I've confirmed this works as expected and the gokeep files are created correctly. Thank you for fixing this!

@lfittl lfittl merged commit 00b50ee into pganalyze:main Apr 3, 2025
lfittl added a commit to pganalyze/collector that referenced this pull request Apr 3, 2025
Thanks to pganalyze/pg_query_go#131

Note this commit removes many ".proto" files in other modules, but its
assumed these are not needed.
lfittl added a commit to pganalyze/collector that referenced this pull request Apr 3, 2025
Thanks to pganalyze/pg_query_go#131

Note this commit removes many ".proto" files in other modules, but its
assumed these are not needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vendoring with go mod vendor leads to "fatal error: 'pg_query.h' file not found"
2 participants