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: applying gofmt to partial code fails if it ends with line comment and no newline #8411

Closed
dmitshur opened this issue Jul 22, 2014 · 5 comments

Comments

@dmitshur
Copy link
Contributor

What does 'go version' print?
go version go1.3 darwin/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

    $ echo -n "foo :=123    // Line comment" | gofmt

What happened?

    <standard input>:1:51: expected '}', found 'EOF'

What should have happened instead?

    foo := 123 // Comment

Please provide any additional information below.

Note that it works fine for block comments:

    $ echo -n "foo :=123    /* Block comment */" | gofmt
    foo := 123 /* Block comment */
@dmitshur
Copy link
Contributor Author

Comment 1:

There's a typo in the What should have happened instead? section and I can't seem to be
able to edit the original issue...
Instead of,
    foo := 123 // Comment
It should read,
    foo := 123 // Line comment

@ianlancetaylor
Copy link
Contributor

Comment 2:

Labels changed: added repo-tools, release-none.

@griesemer
Copy link
Contributor

Comment 3:

Owner changed to @griesemer.

Status changed to Accepted.

@gopherbot
Copy link

Comment 4:

CL https://golang.org/cl/124700043 mentions this issue.

@griesemer
Copy link
Contributor

Comment 5:

This issue was closed by revision 9368d6c.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Fix issue by always appending newline after user input, before
the closing curly bracket. The adjust func is modified to remove
this new newline.

Add test case (it fails before CL, passes after).

Fixes golang#8411.

LGTM=gri
R=golang-codereviews, bradfitz, josharian, gri
CC=golang-codereviews
https://golang.org/cl/124700043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Fix issue by always appending newline after user input, before
the closing curly bracket. The adjust func is modified to remove
this new newline.

Add test case (it fails before CL, passes after).

Fixes golang#8411.

LGTM=gri
R=golang-codereviews, bradfitz, josharian, gri
CC=golang-codereviews
https://golang.org/cl/124700043
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants