Avoid aligning keys and values in source code unnecessarily

7 January 2026 — in Coding, Go

You are reviewing a PR. You see this diff. What has changed?

	user := &User{
-		ID:            uuid.NewString(),
-		Username:      username,
-		EmailAddress:  emailAddress,
-		PasswordHash:  bcrypt(password),
-		IsActive:      true,
-		LoginCount:    0,
-		LastLogin:     time.Now(),
-		Role:          defaultRole,
-		CreatedAt:     time.Now(),
-		EmailVerified: false,
+		ID:              uuid.NewString(),
+		Username:        username,
+		EmailAddress:    emailAddress,
+		PasswordHash:    bcrypt(password),
+		IsActive:        true,
+		PwLastRotatedAt: time.Now(),
+		LoginCount:      0,
+		LastLogin:       time.Now(),
+		Role:            defaultRole,
+		CreatedAt:       time.Now(),
+		EmailVerified:   false,
     }

This diff only adds a single line. With a single “+” line that’d be easy to see.

By formatting the code like this, adding or removing a single long field causes “write amplification”: all the other lines needlessly change as well.

This causes:

Aligning values is the convention in Go (golang), enforced by the Go formatter (gofmt).

There is no readability benefit to this. Java and other languages get by just fine without doing this. Even if there were a readability benefit, it doesn’t outweigh the increased difficulty/mistakes during review, and the increased effort/mistakes during merging.

If you are creating a programming language, or code formatter, don’t do this.

P.S. I recently created a nerdy privacy-respecting tool called When Will I Run Out Of Money? It's available for free if you want to check it out.

This article is © Adrian Smith.
It was originally published on 7 Jan 2026
More on: Coding | Go