结构是
type TopicModels struct {
Topics []string
}
我想像下面的方法一样将值设置到这个结构中
var topics [2]string
topics[0] = "Sport Nice"
topics[1] = "Nice Sport"
return &TopicModels{Topics: topics}, nil
然而,它告诉我
cannot use topics (type [2]string) as type []string in field value
如何更改代码以使其正确?
子衿沉夜
相关分类