DisposaBoy / GoSublime

A Golang plugin collection for SublimeText 3, providing code completion and other IDE-like features.
MIT License
3.42k stars 302 forks source link

gosublime format issue #909

Closed lnshi closed 5 years ago

lnshi commented 5 years ago

when i have code like this:

var extractAllowedHeadersToModelServerTests = []struct {
    desc                        string
    incomingHeaders             map[string]string
    allowedHeadersToModelServer map[string]struct{}
    expect                      []string
}{
    {
        desc: "Test case: HTTP request no headers allowed",
        incomingHeaders: map[string]string{
            "key_1": "value_1",
        },
        allowedHeadersToModelServer: map[string]struct{}{},
        expect: []string{},
    },
}

upon save gosublime will NOT format the code, and i tested with gofmt it doesn't complain, but with goimports it will complain that .go:1::warning: file is not goimported (goimports)

then i run the goimports -w path_to_above_source_file.go, and find out it is complaining the expect: []string{}, line, and it formats it to:

                incomingHeaders: map[string]string{
            "key_1": "value_1",
        },
        allowedHeadersToModelServer: map[string]struct{}{},
        expect:                      []string{},

looks gofmt and goimports conflict with each other?

lnshi commented 5 years ago

https://github.com/golang/go/issues/29863

As here, after updated the go version, gofmt starts complaining also, but gosublime still WILL format it back..., pls help to fix.

lnshi commented 5 years ago

restart sublime solved it, closing...