Skip to content

cmd/gofmt: comments in expr-stmt are not arranged #16078

@hirochachacha

Description

@hirochachacha

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6 darwin/amd

  2. What operating system and processor architecture are you using (go env)?
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH="/Users/hiro/.go"
    GORACE=""
    GOROOT="/Users/hiro/go1.6"
    GOTOOLDIR="/Users/hiro/go1.6/pkg/tool/darwin_amd64"
    GO15VENDOREXPERIMENT="1"
    CC="clang"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
    CXX="clang++"
    CGO_ENABLED="1"

  3. What did you do?
    I was trying to preallocate buffer for encoding.
    After I ran gofmt, I expected comments in expr-stmt are arranged, but not.

    package main
    
    func main() {
        var val []byte
        var name string
    
        buf := make([]byte, 24+ // min buffer size
            4+len(val)+ // tagLen + value
            2+len(name)+1+ // nameLen + name + '\0'
            16) // checksum
    
        _ = buf
    }

    https://play.golang.org/p/wAVUh_sGmw

  4. What did you expect to see?

    package main
    
    func main() {
        var val []byte
        var name string
    
        buf := make([]byte, 24+ // min buffer size
            4+len(val)+         // tagLen + value
            2+len(name)+1+      // nameLen + name + '\0'
            16)                 // checksum
    
        _ = buf
    }
  5. What did you see instead?
    same as input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions