Skip to content

Commit 70a5a10

Browse files
fix: ipns protobuf namespace conflict
1 parent b7d0d20 commit 70a5a10

File tree

5 files changed

+303
-271
lines changed

5 files changed

+303
-271
lines changed

ipns/pb/Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This Makefile is designed to work around namespace conflicts that occur when
2+
# multiple repositories depend on .proto files with generic filenames. Due to
3+
# the way 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+
PKG_PATH = github.com/ipfs/boxo/ipns/pb
16+
PROTONAME = record
17+
PROTOFILE = ${PROTONAME}.proto
18+
19+
all: clean build
20+
21+
build:
22+
mkdir -p ${PKG_PATH}
23+
cp ${PROTOFILE} ${PKG_PATH}
24+
protoc --go_out=. ${PKG_PATH}/${PROTOFILE}
25+
mv ${PKG_PATH}/${PROTONAME}.pb.go .
26+
rm -rf $(firstword $(subst /, ,${PKG_PATH}))
27+
28+
clean:
29+
rm -f *.pb.go
30+
31+
.PHONY: all build clean

ipns/pb/ipns-record.pb.go

-270
This file was deleted.

0 commit comments

Comments
 (0)