You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to shim an interface into something that knows how to properly serialize/deserialize that interface. Here is an example:
package foo
//go:generate go tool msgp -io=false -tests=false//msgp:shim *Bar as:BarSerializer using:ToBarSerializer/unusedFn//msgp:ignore BarSerializer BartypeBarinterface{}
typeFoostruct {
Bar
}
typeBarSerializerstruct {
Bar*Bar
}
funcToBarSerializer(b*Bar) BarSerializer {
returnBarSerializer{Bar: b}
}
func (bBarSerializer) MarshalMsg(o []byte) ([]byte, error) {
// actual logicreturno, nil
}
func (bBarSerializer) UnmarshalMsg(o []byte) ([]byte, error) {
// actual logic*b.Bar=nil// set appropriatelyreturno, nil
}
func (bBarSerializer) Msgsize() int {
return0
}
Using this generation, the shim is completely unused. I believe it is because the .Alias call here does not set .Convert = true when IDENT types are provided in the as. As such, the shim logic isn't used at all in marshal/unmarshal/size.
Unconditionally setting Convert to true for aliases fixes this problem and properly uses the shim.
Activity