我有以下无法编译的代码片段:
func (r *ProviderServer) ListProvider(ctx context.Context, in *emptypb.Empty) (*versioner.ListProvidersResponse, error) {
providers, err := r.store.FindAll()
return &versioner.ListProvidersResponse{Providers: providers}, err
}
编译器抱怨:
cannot use providers (type *[]versioner.ProviderResponse) as type []*versioner.ProviderResponse in field value
的定义如下:ListProviderResponse
type ProviderResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
}
type ListProvidersResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Providers []*ProviderResponse `protobuf:"bytes,1,rep,name=providers,proto3" json:"providers,omitempty"`
}
和 :r.store.FindAll()
type ProviderStore interface {
FindAll() (*[]versioner.ProviderResponse, error)
...
}
我做错了什么?
慕森卡
相关分类