Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/gofmt: Unexpected formatting multiline functions in struct literal #23523
What version of Go are you using (
For the record, I believe that what happens here is that two field values are not aligned if one of them is a multi-line composite literal itself.
So I think this is by design. If you take it to the extreme, this keeps alignment from potentially jumping tens or hundreds of lines past a composite literal, which could be very confusing.
Simply keeping alignments in this case would be a bad idea in my opinion, but perhaps this can be considered in a gofmt redesign along with other imperfect rules such as the "align fields values as long as the names are not too different in length" heuristic.