mvdan / gofumpt

A stricter gofmt
https://pkg.go.dev/mvdan.cc/gofumpt
BSD 3-Clause "New" or "Revised" License
3.15k stars 110 forks source link

Breaks import comment #289

Open AlexanderYastrebov opened 7 months ago

AlexanderYastrebov commented 7 months ago

I've noticed this while playing with formatting go sources

gofumpt -d ./net/dnsclient.go
diff ./net/dnsclient.go.orig ./net/dnsclient.go
--- ./net/dnsclient.go.orig
+++ ./net/dnsclient.go
@@ -5,15 +5,19 @@
 package net

 import (
+       "sort"
+       _ "unsafe"
+
        "internal/bytealg"
        "internal/itoa"
-       "sort"
-       _ "unsafe" // for go:linkname
+
+       // for go:linkname

        "golang.org/x/net/dns/dnsmessage"
 )

 // provided by runtime
+//
 //go:linkname runtime_rand runtime.rand
 func runtime_rand() uint64
mvdan commented 5 months ago

Yep, for better or worse, this is how comments in Go work at the moment. Reordering or moving imports is also a bit broken right now, e.g. see https://github.com/mvdan/gofumpt/issues/225. The handling of import declarations needs a bit of a rethink.