Skip to content
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

fix: ipns protobuf namespace conflict #794

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following emojis are used to highlight certain changes:
### Fixed

- `gateway` Fix redirect URLs for subdirectories with characters that need escaping. [#779](https://github.com/ipfs/boxo/pull/779)
- `ipns` Defined a `go_package` name in `ipns-record.proto` to avoid protobuf conflicts [#789](https://github.com/ipfs/boxo/pull/789)
- `ipns` Fix `ipns` protobuf namespace conflicts by using full package name `github.com/ipfs/boxo/ipns/pb/record.proto` instead of the generic `record.proto` [#794](https://github.com/ipfs/boxo/pull/794)

### Security

Expand Down
20 changes: 20 additions & 0 deletions ipns/pb/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// These commands work around namespace conflicts that occur when multiple
// repositories depend on .proto files with generic filenames. Due to the way
// protobuf registers files (e.g., foo.proto or pb/foo.proto), naming
// collisions can occur when the same filename is used across different
// packages.
//
// The only way to generate a *.pb.go file that includes the full package path
// (e.g., github.com/org/repo/pb/foo.proto) is to place the .proto file in a
// directory structure that mirrors its package path.
//
// References:
// - https://protobuf.dev/reference/go/faq#namespace-conflict
// - https://github.com/golang/protobuf/issues/1122#issuecomment-2045945265
//
//go:generate mkdir -p github.com/ipfs/boxo/ipns/pb
//go:generate ln -f record.proto github.com/ipfs/boxo/ipns/pb/
//go:generate protoc --go_out=. github.com/ipfs/boxo/ipns/pb/record.proto
//go:generate mv -f github.com/ipfs/boxo/ipns/pb/record.pb.go .
//go:generate rm -rf github.com
package pb
270 changes: 0 additions & 270 deletions ipns/pb/ipns-record.pb.go

This file was deleted.

Loading
Loading