Write data from two channels into the structure

Good afternoon, I apologize for such a perhaps simple question, but this is the first time I encounter such a task, I receive data from two channels, how to properly write them into one structure?

type valChannels struct {
  valueCh1 type
  valueCh2 type
}

go func() {
  for vCh1 := channel1 {
    fmt.Println(vCh1)
  }
}()

go func() {
  for vCh2 := channel2 {
   fmt.Println(vCh2)
  }
}()

How can I write the values I get from the channels into one structure so that I can output

fmt.Println(&valChannels{
  vCh1,
  vCh2,
})
for {
  v1, ok := <- channel1
  if !ok {
    return
  }
  v2, ok := <- channel2
  if !ok {
    return
  }
  fmt.Println(v1,v2)
}

Thanks :blush:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.