Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hirochachacha opened this issue Jun 16, 2016 · 1 comment
Open

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

hirochachacha opened this issue Jun 16, 2016 · 1 comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hirochachacha
Copy link
Contributor

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.

@griesemer
Copy link
Contributor

Agreed that the expected output is much nicer. We should try to fix this at some point.

@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants