Skip to content

cmd/gofmt: indenting removed from multi-line bullet-lists inside numbered lists #56072

@thaJeztah

Description

@thaJeztah

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

$ go version
go version go1.19.2 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

(probably not relevant)

What did you do?

Given the following file;

/*
Package main is an example.

 1. Item 1.
 2. Item 2.
    - SubItem 1.
    - SubItem 2.
    - SubItem 3 spans two lines. Lorem ipsum dolor sit amet, consectetur
      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
    - Subitem 3 spans three lines. Lorem ipsum dolor sit amet, consectetur
      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
      Mauris nisi magna, faucibus quis velit vitae, euismod convallis magna.
*/
package main

Running gofmt reformat the bullet-list, removing the indentation for bullets spanning multiple lines;

gofmt -d .
diff main.go.orig main.go
--- main.go.orig
+++ main.go
@@ -6,9 +6,9 @@
     - SubItem 1.
     - SubItem 2.
     - SubItem 3 spans two lines. Lorem ipsum dolor sit amet, consectetur
-      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
+    adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
     - Subitem 3 spans three lines. Lorem ipsum dolor sit amet, consectetur
-      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
-      Mauris nisi magna, faucibus quis velit vitae, euismod convallis magna.
+    adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
+    Mauris nisi magna, faucibus quis velit vitae, euismod convallis magna.
 */
 package main

I also tried adding whitespace after the bullet-list (following the example at https://go.dev/doc/comment#mistakes):

/*
Package main is an example.

 1. Item 1.

 2. Item 2.

    - SubItem 1.
    - SubItem 2.
    - SubItem 3 spans two lines. Lorem ipsum dolor sit amet, consectetur
      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
    - Subitem 3 spans three lines. Lorem ipsum dolor sit amet, consectetur
      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
      Mauris nisi magna, faucibus quis velit vitae, euismod convallis magna.
*/
package main

But this gave the same result;

gofmt -d .
diff main.go.orig main.go
--- main.go.orig
+++ main.go
@@ -8,10 +8,9 @@
     - SubItem 1.
     - SubItem 2.
     - SubItem 3 spans two lines. Lorem ipsum dolor sit amet, consectetur
-      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
+    adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
     - Subitem 3 spans three lines. Lorem ipsum dolor sit amet, consectetur
-      adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
-      Mauris nisi magna, faucibus quis velit vitae, euismod convallis magna.
+    adipiscing elit. Morbi porta eros nunc, in viverra ex porttitor vitae.
+    Mauris nisi magna, faucibus quis velit vitae, euismod convallis magna.
 */
 package main

What did you expect to see?

The indentation preserved.

What did you see instead?

The indentation removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions