go icon indicating copy to clipboard operation
go copied to clipboard

x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment: comments are removed

Open yuyongbo opened this issue 2 years ago • 0 comments

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

$ go version
go version go1.16.13 darwin/arm64

Does this issue reproduce with the latest release?

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

go env Output
$ go env

What did you do?

When I execute the following command, I found that the field comments in the fixed struct are not preserved, you can try it, I don't quite understand why the original comments are removed. Please take a look, thank you.

$ fieldalignment -fix ./... 

What did you expect to see?


type UserLoginStatus struct {
	Type        uint8  `json:"type"`                   // 1:online,2: offline
	UserID      string `json:"user_id"`                // userid
	DeviceID    string `json:"device_id"`              // IMEI
}

What did you see instead?


type UserLoginStatus struct {
	UserID      string `json:"user_id"`                
	DeviceID    string `json:"device_id"`        
        Type        uint8  `json:"type"`                      
}

yuyongbo avatar Aug 08 '22 06:08 yuyongbo