Skip to content

cmd/gofmt: align struct tag of embedded type with surrounding fields #51598

@dolmen

Description

@dolmen

Struct tag of embedded types is not aligned with tags of surrounding struct fields.

What version of Go are you using (go version)?

$ go version
go version go1.17.8 darwin/amd64

Does this issue reproduce with the latest release?

Yes (1.17.8).

Also gotip on the Go Playground.

What did you do?

Apply gofmt to the following code.

type B string

type _ struct {
	A string `json:"a"`
	B `json:"b"`
	C int     `json:"c"`
	D float32 `json:"d"`
}

Use the 'Format' button on the Go Playground.

What did you expect to see?

type _ struct {
	A string  `json:"a"`
	B         `json:"b"`
	C int     `json:"c"`
	D float32 `json:"d"`
}

What did you see instead?

No change in formatting.

type _ struct {
	A string `json:"a"`
	B `json:"b"`
	C int     `json:"c"`
	D float32 `json:"d"`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions