Skip to content

Commit d443b97

Browse files
committed
Prefer go generate to Makefile for code generation
1 parent c13acda commit d443b97

File tree

2 files changed

+20
-31
lines changed

2 files changed

+20
-31
lines changed

ipns/pb/Makefile

-31
This file was deleted.

ipns/pb/gen.go

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This commands work around namespace conflicts that occur when multiple
2+
// repositories depend on .proto files with generic filenames. Due to the way
3+
// protobuf registers files (e.g., foo.proto or pb/foo.proto), naming
4+
// collisions can occur when the same filename is used across different
5+
// packages.
6+
//
7+
// The only way to generate a *.pb.go file that includes the full package path
8+
// (e.g., github.com/org/repo/pb/foo.proto) is to place the .proto file in a
9+
// directory structure that mirrors its package path.
10+
//
11+
// References:
12+
// - https://protobuf.dev/reference/go/faq#namespace-conflict
13+
// - https://github.com/golang/protobuf/issues/1122#issuecomment-2045945265
14+
//
15+
//go:generate mkdir -p github.com/ipfs/boxo/ipns/pb
16+
//go:generate ln -f record.proto github.com/ipfs/boxo/ipns/pb/
17+
//go:generate protoc --go_out=. github.com/ipfs/boxo/ipns/pb/record.proto
18+
//go:generate mv github.com/ipfs/boxo/ipns/pb/record.pb.go .
19+
//go:generate rm -rf github.com
20+
package pb

0 commit comments

Comments
 (0)