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, internal/format: Gofmt function chaining with lambda issue #12066

Closed
mathvav opened this issue Aug 7, 2015 · 4 comments
Closed

cmd/gofmt, internal/format: Gofmt function chaining with lambda issue #12066

mathvav opened this issue Aug 7, 2015 · 4 comments
Assignees
Milestone

Comments

@mathvav
Copy link

@mathvav mathvav commented Aug 7, 2015

Take this code here:

package main

import "fmt"

type FoobarType struct{}

func (ft *FoobarType) Run(f func()) *FoobarType {
    f()
    return ft
}

func (ft *FoobarType) DoNothing() *FoobarType {
    return ft
}

func main() {
    f := FoobarType{}
    f.Bar().
        DoNothing().
        Run(
            func() {
                fmt.Println("Hi")
            },
        )
}

The issue is when I run go fmt myproject, it changes the main body to this:

func main() {
    f := FoobarType{}
    f.Bar().
        DoNothing().
        Run(
        func() {
            fmt.Println("Hi")
        },
    )
}

Lines 6-9 should be indented one line further. What is the cause of this?

@griesemer griesemer added this to the Go1.6 milestone Aug 7, 2015
@griesemer griesemer self-assigned this Aug 7, 2015
@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 7, 2015

Looks like an indentation bug.

@mikioh mikioh changed the title Gofmt function chaining with lambda issue cmd/gofmt. internal/format: Gofmt function chaining with lambda issue Aug 10, 2015
@griesemer griesemer changed the title cmd/gofmt. internal/format: Gofmt function chaining with lambda issue cmd/gofmt, internal/format: Gofmt function chaining with lambda issue Aug 21, 2015
@mibk
Copy link
Contributor

@mibk mibk commented Aug 23, 2015

Just to put another example, I would expect the following:

func main() {
    f := FoobarType{}
    f.Bar().
        Run(func() {
        fmt.Println("Hi")
    }).
        Set(map[string]interface{}{
        "baz": "syd",
        "bag": 13,
    })
}

to rather look like this:

func main() {
    f := FoobarType{}
    f.Bar().
        Run(func() {
            fmt.Println("Hi")
        }).
        Set(map[string]interface{}{
            "baz": "syd",
            "bag": 13,
        })
}
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 27, 2015

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

@mibk
Copy link
Contributor

@mibk mibk commented Aug 27, 2015

@griesemer griesemer closed this in ab14797 Sep 11, 2015
@golang golang locked and limited conversation to collaborators Sep 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.