Skip to content

gofmt can emit code that does not compile #1089

@gopherbot

Description

@gopherbot

by akidan:

gofmt can emit code that does not compile if a field in a multiline struct literal is
followed immediately by a single-line comment

What steps will reproduce the problem?
1. run gofmt on the sample program attached
(important part is as follows:)
var notOk s = s{
    a: 1,//
}

What is the expected output?
var notOk s = s{
    a: 1, //
}

What do you see instead?
var notOk s = s{
    a: 1 //
    ,
}

What is your $GOOS?  $GOARCH?
darwin amd64

Which revision are you using?  (hg identify)
e004d329064a+ tip

Please provide any additional information below.

Attachments:

  1. sample.go (96 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions