Advanced Golang: Goroutines & Channels

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 11

  • @sheikhAbdelrahman
    @sheikhAbdelrahman Месяц назад +1

    Hello .. thanks for the video. But actually you didn't need waitgroups here.
    as long as you are iterating through the ch values, you could simply use an integer counter, which increments each time you read, then a simple if condition to check if the read becomes = to the go-routines you've spawned then you can close the channel.
    counter := 0
    for msg := range ch {
    log.Println(msg)
    counter++
    if counter == 2 {
    close(ch)
    }
    }

  • @john.dough.
    @john.dough. 9 месяцев назад

    Thank you so much for showing the errors and ways things can go wrong! Very insightful! :]

  • @licokr
    @licokr 9 месяцев назад

    Nice work! 👍 thanks for the video!

  • @prashlovessamosa
    @prashlovessamosa 9 месяцев назад

    Thanks for sharing Bud.

  • @inteliconn995
    @inteliconn995 9 месяцев назад +1

    Thanks!

  • @vb_gh
    @vb_gh 6 месяцев назад

    Nice video🙏🏽. Also could you explain what you meant over here? I couldn’t really understand you.
    You said when we use channels in this manner, what?
    15:08
    Thanks in advance for your explanation.

  • @aadilkp5335
    @aadilkp5335 9 месяцев назад

    Great video! Thanks

  • @rafael.aloizio1769
    @rafael.aloizio1769 7 месяцев назад

    Hey Tiago, great video man. Could you please share your theme? Or is this a custom highlighting?

    • @TiagoTaquelim
      @TiagoTaquelim  7 месяцев назад +1

      Thanks! It's called Gruvebox.

  • @sundayezeilo192
    @sundayezeilo192 7 месяцев назад

    @TiagoTaquelim How are we able to range over a channel after closing it? Would it add any benefit if we executed wg.Wait() and close(ch) in a separate goroutine?

    • @TiagoTaquelim
      @TiagoTaquelim  7 месяцев назад

      Hey! wg.Wait is syncrhonous (it blocks the flow of the program) it cannot be in a goroutine.
      We cannot range a closed channel, it will panic.