channels 是一个切片,这样写通过了编译
func (j *gameChannelKickJob) Produce(ctx context.Context, tasks chan<- interface{}) {
channels, err := dao.GetAllActiveGameChannel(ctx, model.GAME_CHANNEL_ACTIVE)
tasks <- channels
}
当这样写,编译不通过提示 mismatched types ,同样是向 chan 塞切片,为啥啊
func (j *gameChannelKickJob) Produce(ctx context.Context, tasks chan<- interface{}) {
channels, err := dao.GetAllActiveGameChannel(ctx, model.GAME_CHANNEL_ACTIVE)
for k,_ := range channels {
oneSlice := dao.GetSomeSliceData(ctx,channels[k])
tasks <- oneSlice
}
}
1
lysS 2023-04-03 12:51:31 +08:00
我去,go 里面出现了 dao?
你这个类型报错不是在 `tasks <- oneSlice` 那行 |