pganalyze / pg_query_go

Go library to parse and normalize SQL queries using the PostgreSQL query parser
BSD 3-Clause "New" or "Revised" License
663 stars 79 forks source link

Use Go Protobuf APIv2 #30

Closed johanbrandhorst closed 1 year ago

johanbrandhorst commented 3 years ago

Hi Lukas, thanks for this library, it's the base for sqlc which is my favourite Go SQL library, and I'm very grateful! I had a quick look at your protobuf generation strategy after you mentioned it in https://github.com/kyleconroy/sqlc/issues/948, and as I'm a bit of a subject matter expert, I'd recommend migrating to the new APIv2 tooling in https://pkg.go.dev/google.golang.org/protobuf/. Judging by your go.mod this should be a simple affair as you're already on v1.4.2 of the github.com/golang/protobuf module. It should just be a matter of replacing any imports of the old library with the new and changing the generator to google.golang.org/protobuf/cmd/protoc-gen-go. You can read more about the APIv2 features here: https://blog.golang.org/protobuf-apiv2.

Sidenote, I work for Buf (creators of https://github.com/bufbuild/buf), and we're working on making protobuf tooling better for everyone (and we're using sqlc in our internal codebase!). For a simple generation use case such as yours, it may not be worth replacing your existing generation strategy, but I would recommend taking a look at our linting and breaking change detection tooling. It's all documented on our docs site: https://docs.buf.build/. I'd be happy to explain in more detail if you have any questions around it.

Thanks again for the great library!

lfittl commented 3 years ago

@johanbrandhorst Nice, good catch - I'll make that change :)

dropwhile commented 1 year ago

go mod reports the following when using github.com/pganalyze/pg_query_go/v4 as a dependency :

go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead.