Skip to content

Commit

Permalink
Prefer go generate to Makefile for code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Jan 20, 2025
1 parent c13acda commit d443b97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
31 changes: 0 additions & 31 deletions ipns/pb/Makefile

This file was deleted.

20 changes: 20 additions & 0 deletions ipns/pb/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This 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 github.com/ipfs/boxo/ipns/pb/record.pb.go .
//go:generate rm -rf github.com
package pb

0 comments on commit d443b97

Please sign in to comment.