Skip to content

proposal: cmd/gofmt formatting/alignment of multiple struct tags #16918

@deankarn

Description

@deankarn

This is a proposal to add functionality to gofmt for formatting/alignment of multiple struct tags. If gofmt could align the tags it would become much more readable and save allot of time from having to do it manually.

example: ( just some tags I use, could be many others )

type User struct {
    Name      string `json:"name" bson:"name" validate:"required"`
    LegalName string `json:"legalName" bson:"legalName" validate:"required"`
    Email     string `json:"email" bson:"email" validate:"required"`
        ....
}

after gofmt:

type User struct {
    Name      string `json:"name"      bson:"name"      validate:"required"`
    LegalName string `json:"legalName" bson:"legalName" validate:"required"`
    Email     string `json:"email"     bson:"email"     validate:"required"`
        ...
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions