fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.98k stars 1.45k forks source link

GoFillStruct with proto pb.go #3655

Closed onns closed 5 months ago

onns commented 6 months ago

What did you do? (required: The issue will be closed when not provided)

What did you expect to happen?

can GoFillStruct ignore unknown fields of grpc proto pb file?

type CollectionBase struct {
    BizType int64 `protobuf:"varint,1,opt,name=biz_type,proto3" json:"biz_type" form:"biz_type"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

maybe struct like this, run GoFillStruct will add XXX... to the code, Which is no use for coding.

I use gopls:

vim.g.go_fillstruct_mode = "gopls"
bhcleek commented 5 months ago

Ultimately, vim-go delegates the changes to fill the struct to gopls or fillstruct. While these fields are annoying in protobufs, they may exist in other structures for reasons that may be useful to clients.

Also, protoc-gen-go was updated four years ago to no longer generate these fields.

refs:

edit: typos