Skip to content

Add support for renaming fields #436

@natewernimont-wk

Description

@natewernimont-wk

I have fields that we forgot to initially define a msgp tag for, so our msgp generation is using the full name of the field. This can be quite long, and it would be ideal to have a built-in way to rename the msgp tag - this would add a configuration in the tag for old aliases. The generated code would then support unmarshaling into a particular field using that old tag. Marshalling would use the new tag.

Example:

type Name struct {
	CurrentName string `msg:"CurrentName"`
}

has a quite long field, causing storage bloat. We could add an alias:

type Name struct {
	CurrentName string `msg:"cn,aliases=CurrentName"`
}

To be rollback safe, one might want to add the new name as an alias first (i.e. msg:"CurrentName,aliases=cn").

It could also support multiple aliases that are ; delimited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions