tinylib / msgp

A Go code generator for MessagePack / msgpack.org[Go]
MIT License
1.81k stars 192 forks source link

`replace` directive #346

Closed infastin closed 4 months ago

infastin commented 6 months ago

Adds a replace directive that makes it easier to serialize foreign types.

Example usage with github.com/google/uuid ```go package main import "github.com/google/uuid" //go:generate msgp //msgp:replace uuid.UUID with:UUID type UUID [16]byte // Or like that //msgp:replace uuid.UUID with:[16]byte type User struct { ID uuid.UUID } ```

Also adds any to the list of primitives.

klauspost commented 6 months ago

So this will work when the type is a primitive?

LGTM, though.

infastin commented 6 months ago

So this will work when the type is a primitive?

Should work with any type that msgp can work with.

Please add a suite of tests.

Added some tests.

klauspost commented 6 months ago

You can bump CI to 1.21 and 1.22 if that help.

infastin commented 6 months ago

Sorry, didn't notice it was go1.18, should be fine now.

klauspost commented 6 months ago

Thanks! Giving it a bit of time to see if there are any objects before merge.

klauspost commented 4 months ago

@infastin Seems we've picked up a conflict. Could you resolve that, and I'll merge ASAP.

infastin commented 4 months ago

@klauspost Resolved.