Closed onns closed 7 months ago
The syntax in your example is invalid. The comma after the cursor is unnecessary, because you're dealing with the empty struct and there are no fields to separate. Also, there is no comma after the final element's }
and just before the newline after which follows the slice's closing }
.
I assume that the example you provided is not quite what you're seeing in practice. If you can provide an example that's syntactically correct, we may be able to discover the root of the problem you're having.
package main
import "fmt"
type Foo struct {
S string `json:"s"`
N int64 `json:"n"`
}
func main() {
fs := []*Foo{
{
// cursor here does not work
},
}
fs := []Foo{
{
// cursor here work well.
S: "",
N: 0,
},
}
}
sorry for the bad example, I thought it wouldn't work while handling struct slice so I write a simple example, but after I tested, only []*struct
has the problem.
If you'll change change the fillstruct mode with let g:go_fillstruct_mode='gopls'
, I think the case slice of pointers case will work, too.
If you want to continue to use fillstruct
for g:go_fillstruct_mode
, then I'd suggest opening an issue at https://github.com/davidrjenni/reftools.
What did you do? (required: The issue will be closed when not provided)
_
means the cursor, under command model and I typeGoFillStruct
, it doesn't do what I expected.What did you expect to happen?
What happened instead?
Configuration (MUST fill this out):
vim-go version:
vimrc
you used to reproduce:vimrc
```vim ```Vim version (first three lines from
:version
):Go version (
go version
):Go environment
go env
Output:gopls version
gopls version
Output: