2015-06-29 00:19
浏览 40


The structure is

type TopicModels struct {
    Topics []string

And I want to set the value into this structure like following approach

var topics [2]string
topics[0] = "Sport Nice"
topics[1] = "Nice Sport"
return &TopicModels{Topics: topics}, nil

However, it tells me that

 cannot use topics (type [2]string) as type []string in field value

How can I change the code to make it correct?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题