learn the Go concurrency pattern that blew my mind

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ส.ค. 2024
  • Golang, Go Programming concurrency patterns continued
    🌟 Hey devs! 🌟
    Ready to level up your coding game? Check out this awesome course on Microservices using Go!
    🚀 From beginner to pro, learn to build scalable apps with ease. Don't miss out!
    Enroll now: 👉 kantan-coding....
    #golanguage #Microservices #CodeWithConfidence 🔥🎉
    Join the Discord to talk to me and the rest of the community!
    / discord
    Book on Concurrency in Go: www.oreilly.co...

ความคิดเห็น • 38

  • @michelemendel
    @michelemendel 5 หลายเดือนก่อน +8

    Your videos about concurrency in Go are very good.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +1

      Thank you! I’m glad that they are helpful 😊

  • @bjugdbjk
    @bjugdbjk 5 หลายเดือนก่อน +3

    I was always confused with orDone, now its clear, Thank you!
    And appreciate the last piece of explaining the complete code as a snippet,that was helpful.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน

      Thanks for watching! I’m glad it was helpful 😊

  • @paracha3
    @paracha3 8 วันที่ผ่านมา

    Your teaching style is very good specially with conceptual diagram before or after coding. That is something not many youtuber do.

    • @kantancoding
      @kantancoding  8 วันที่ผ่านมา

      Thank you! I’m happy it was helpful

  • @naehalmulazim
    @naehalmulazim 5 หลายเดือนก่อน +1

    Congratulations on your course! I've been following you since your clean architecture videos, which were an absolute game changer for my mindset. Definitely going to try and save up time and money for this course. In the meantime thanks for all your splendid free content.
    I have never never never considered purchasing a course, and especially not in a language Ive been learning almost since when your content started but if you're interested, I feel like I'm not doing enough vanilla stuff at my current company and it's debilitating and I have never actually taken a microservice to production all by myself before, so even more debilitating.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +1

      Hey! Thank you so much for your support. I’ll still be posting plenty of free content as well so stay tuned😊
      P.s. it really means a lot to me that you’ve stuck around for so long. Thank you for telling me. It made my day 🙂

    • @naehalmulazim
      @naehalmulazim 5 หลายเดือนก่อน

      Of course, you're an inspiration, and please, keep it going!@@kantancoding

  • @mailman2097
    @mailman2097 หลายเดือนก่อน

    best explanations on go concurrency i found on TH-cam

  • @matthew1106
    @matthew1106 5 หลายเดือนก่อน +1

    This is an interesting concept. Thanks for sharing.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน

      My pleasure!

  • @muffawuffaman
    @muffawuffaman 3 หลายเดือนก่อน +1

    I like this pattern, wish this were a builtin in Go.
    one thing - wouldn't it be better to use generic types in the signature of orDone so that you're not losing type info by wrapping the channel?

  • @bjugdbjk
    @bjugdbjk 5 หลายเดือนก่อน

    Awesome,u r back with a bang !!!

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +1

      Life got a bit busy but I’m back! Stay tuned for more videos 😊

    • @bjugdbjk
      @bjugdbjk 5 หลายเดือนก่อน

      @@kantancoding do more videos on teh topics like performance analysis and a typical tech stack what used mostly in the production or based on your experience, that will really give some insights which really helps budding Go lang devs.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน

      Perf analysis sounds fun. Let me see what I can come up with

  • @dawnrazor
    @dawnrazor 3 หลายเดือนก่อน

    Hi @kantancoding, great video and that’s a pattern I’ll look to use in my concurrency projects.

    • @kantancoding
      @kantancoding  3 หลายเดือนก่อน +1

      It’s very useful!

  • @marchayes5434
    @marchayes5434 5 หลายเดือนก่อน +2

    Why not make use a `context.Context`? It is the same functionality but with better ergonomics and broader support.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +5

      Yes, you are absolutely correct my friend. Good insight 😉
      Basically, this video is to teach the orDone pattern. The context package needs its own entirely separate video (which I am currently making). I did not want to convolute the explanation of the orDone pattern with context package stuff.
      But! for those that want to jump ahead, this is what the code looks like replacing the done channel with the context package(the pattern does not change):
      package main
      import (
      "context"
      "fmt"
      "sync"
      )
      var wg sync.WaitGroup
      func main() {
      ctx, cancel := context.WithCancel(context.Background())
      defer cancel()
      cows := make(chan interface{}, 100)
      go func() {
      for {
      select {
      case

  • @Dan-rx8wf
    @Dan-rx8wf 5 หลายเดือนก่อน +2

    nested selects made me feel sad :D Sometimes repetitive/verbose code is way cheaper and easier to maintain than smart abstractions.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน

      Hmm, there's a discussion about this in the pinned comment where I responded to a similar comment if you're interested. But aside from that, thanks for watching and contributing 😊

    • @justintie
      @justintie 10 วันที่ผ่านมา

      what you said is actually the go way

  • @marcialabrahantes3369
    @marcialabrahantes3369 หลายเดือนก่อน

    isn't there another more common pattern (i.e. in other languages) suitable for the "orDone" function ?
    I'd imagine a decorator pattern will suffice without the extra relay chan

  • @kirannhegde
    @kirannhegde 11 วันที่ผ่านมา

    Where can i find the code samples?

  • @stevenodlum4563
    @stevenodlum4563 5 หลายเดือนก่อน

    I feel like this pattern should be called untilDone rather than orDone. For example:
    for val in range untilDone
    linguistically makes more sense than
    for val in range orDone
    Calling it orDone tells me that we're either doing something or we're not doing something. Calling it untilDone tells me that we're doing something UNTIL we're not doing something, essentially doing the thing until the thing is done rather than doing the thing or not doing the thing.

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +1

      I kind of feel like "range until done" implies that we will in fact range. But if the channel is closed we won't range at all.
      that's why I think "range or done" is used. We'll range if the channel isn't closed or we'll be done.
      But of course, naming is subjective and is probably the most difficult part of programming 😆

    • @michelemendel
      @michelemendel 5 หลายเดือนก่อน

      The name "orDone" is more aligned with concepts from functional programming, like "maybe".

  • @Rakstawr
    @Rakstawr 4 หลายเดือนก่อน

    Good work here.

    • @kantancoding
      @kantancoding  4 หลายเดือนก่อน

      Thank you! Cheers!

  • @Wickedism
    @Wickedism 4 หลายเดือนก่อน

    Why would you need two select statements in the orDone function instead of using an additional case? Is there a language rule for this use case?

    • @kantancoding
      @kantancoding  4 หลายเดือนก่อน

      Hi, I explain this in the video 🙂

  • @HarishKumar-jm5bk
    @HarishKumar-jm5bk 5 หลายเดือนก่อน

    Can u please upload that microservice in go in your youtube also

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +1

      🤔 sorry, I cannot. That wouldn’t be fair to the people that have paid for the course.

  • @a7kerkh
    @a7kerkh 5 หลายเดือนก่อน

    Bro stop making every video about concurrency in go

    • @kantancoding
      @kantancoding  5 หลายเดือนก่อน +3

      Bro, I’m not AI. You can’t give me orders 😂🤣
      Anyways, what types of videos do you want to see?

    • @hvstech9018
      @hvstech9018 2 หลายเดือนก่อน +3

      ​@@kantancodingPls don't listen to him... we're enjoying it 😎