mirror of
https://github.com/zap-proto/pb2zap.git
synced 2026-10-30 15:04:14 +00:00
Syntactic go/ast codemod (runs on non-compiling trees). v1 rewrites the one
transform that is unambiguous from syntax — message construction:
&pb.Msg{F:v} / pb.Msg{F:v} -> wire.NewMsg(wire.MsgInput{F:v})
fixes imports (add wire, drop pb when fully unused), and reports the pb
selectors it leaves (field reads/writes a human owns — immutable ZAP has no
field-write; reads need accessors, which need type info).
Rule{PB,Wire,Name}; Rewrite(file,src,rules)->(out,changed,pbLeft); CLI
pb2zap -map rules.txt [-w] ./... Pure transform + thin CLI, x/tools only.
Tested: construction rewrite + import drop; import-kept-when-still-used.
NOTE: v1 is the safe scaffold. Construction alone changes a value's type
(*pb.Msg -> []byte), so a full tree migration needs the COORDINATED type-
aware transform (construct + client-call + field-read together) = v2.
3 lines
157 B
Plaintext
3 lines
157 B
Plaintext
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
|
|
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
|