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

feature-request: Initialize struct instance command #1425

Closed
josephbuchma opened this issue Sep 3, 2017 · 1 comment · Fixed by #1443
Closed

feature-request: Initialize struct instance command #1425

josephbuchma opened this issue Sep 3, 2017 · 1 comment · Fixed by #1443
Labels

Comments

@josephbuchma
Copy link

It would be nice to have something like :GoInitStruct.

Proposed workflow.

Consider we have this struct:

type Car struct {
    Name string
    Color string
    Weight int
}

And when I create instance of it

car := &Car{}

I place a cursor at Car{} and run :GoInitStruct, which converts the code to:

car := &Car{
    Name: "",
    Color: "",
    Weight: 0,
}

[ideally] it also moves cursor to the first field value assignment [where I can start editing it immediately], and when I press Tab (for example), it moves cursor to next field assignment.

@josephbuchma josephbuchma changed the title feature-request: Initialize struct instance by zero values feature-request: Initialize struct instance command (:GoInitStruct) Sep 3, 2017
@josephbuchma josephbuchma changed the title feature-request: Initialize struct instance command (:GoInitStruct) feature-request: Initialize struct instance command Sep 3, 2017
@arp242 arp242 added the feature label Sep 6, 2017
@fatih
Copy link
Owner

fatih commented Sep 11, 2017

There is a tool already for this. I've talked with @davidrjenni back in GopherCon to implement something like this. Happy for us he did it with https://github.com/davidrjenni/reftools/tree/master/cmd/fillstruct all we need is to integrate into vim-go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants