-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Include keyify support #1258
Include keyify support #1258
Conversation
Includes support for https://github.com/dominikh/go-tools/tree/master/cmd/keyify through the GoKeyify command. Turns unkeyed struct literals into keyed struct literals.
plugin/go.vim
Outdated
@@ -21,6 +21,7 @@ let s:packages = [ | |||
\ "github.com/fatih/gomodifytags", | |||
\ "github.com/zmb3/gogetdoc", | |||
\ "github.com/josharian/impl", | |||
\ "github.com/dominikh/go-tools/tree/master/cmd/keyify", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a wrong import path, should be: github.com/dominikh/go-tools/cmd/keyify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Changed it.
Hi @thalesmello I just tried it. The example I've used is: package main
import "fmt"
type Foo struct {
foo string
bar string
qux string
}
func main() {
f := Foo{"foo", "bar", "qux"}
fmt.Printf("f = %+v\n", f)
}
package main
import "fmt"
type Foo struct {
foo string
bar string
qux string
}
func main() {
Foo{
foo: "foo",
bar: "bar",
qux: "qux",
}
fmt.Printf("f = %+v\n", f)
} As you see it removes the variable all together. I assume the replacement is not done correctly. |
I think we could implement some kind of mechanism to try to figure out the position of the struct, however, I can't think of a good way of implementing it in a good, clear way. But I totally agree that it at least should output some nice error message. In my first implementation, I simply did nothing when I What I did, then, was simply return Now it returns
When it doesn't find any struct. What do you think about this? Hum, strange. It work correctly for me. A common issue with Could you please check my changes? |
Do not use
How do we know that it doesn't work. Does it return an error? I'm always inside a GOPATH. vim-go also has with Go 1.8 a default GOPATH as well.
The problem occurs if you previously have selected anything. For example do a line seletion via "shift-v" and then call |
I changed the echo function used. About the bug, here is what happened:
In order to prevent this bug, now the function checks if the correct visual mode is being used. Could you check this last version, please? |
Thanks @thalesmello this looks now good 👍 |
Includes support for https://github.com/dominikh/go-tools/tree/master/cmd/keyify
through the
GoKeyify
command.It turns unkeyed struct literals into keyed struct literals.