Go (Golang) Context Tutorial

Go (Golang) Context Tutorial
In this video we go through the context package and how it can be used to propagate cancellation signals across different parts of our Go programs
Context Package - golang.org/pkg/context/
Source Code - play.golang.org/p/y3wOa9O3xGr
💼 Golang Cafe - golang.cafe
📬 Golang Cafe Jobs Newsletter - golang.cafe/newsletter
🐦 Golang Cafe Twitter - / golangcafe
📣 Telegram Channel - t.me/golangcafe
🙏 Found this video useful? Help me make more by donating $5.00 - golang.cafe/5USD

Пікірлер: 31

  • @skuldd
    @skuldd Жыл бұрын

    The best tutorial I have ever seen about the theme, congratulations!

  • @derdere7803
    @derdere78032 жыл бұрын

    Kind of video you wish you could give a couple of thumbs up. I really like your style. You start easy and built up in complexity with usage of official docs. And I generally like the examples you give. Very relatable in real life. Please continue producing my friend.

  • @robertjmccabe
    @robertjmccabe Жыл бұрын

    The best explanation of Go's context package I've seen.

  • @anon101hide2
    @anon101hide22 жыл бұрын

    Shouldn't latency := rand.Intn(maxLatency-minLatency+1) - minLatency be latency := rand.Intn(maxLatency-minLatency+1) + minLatency instead?

  • @RadhamaniRamadoss
    @RadhamaniRamadoss Жыл бұрын

    This is the best explanation about channels. I understood very well. Please post more videos on opensource projects and code review and some golang realtime projects

  • @RogiervandenBerg
    @RogiervandenBerg2 жыл бұрын

    Amazing and underrated video IMHO. The best tutorial I could find on Contexts 👏

  • @DiakoSharifi
    @DiakoSharifi3 жыл бұрын

    Thank you, finally I find a good tutorial for context

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Thanks Diako, I am glad you liked it

  • @natorverinumbe6511
    @natorverinumbe65113 жыл бұрын

    This is the best explanation I have seen . Thanks a trillion man🤜🤛

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Thanks Nator!

  • @zuzuleinen
    @zuzuleinen11 күн бұрын

    Great video! Very clear explanations. Thank you!! 🙏 Just curios: Do we actually need to do a for select, or a select would have been enough because is already blocking while waiting for channel operations?

  • @tanoybhowmick8715
    @tanoybhowmick87153 жыл бұрын

    explained in a better way. Thanks

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Glad it helped!

  • @victornoagbodji
    @victornoagbodji3 жыл бұрын

    🙏 🙏 😊 thanks for doing these videos. was wondering if you could do a go environment setup video?! 🤔 with modules, packages, etc... it's very confusing now 😅 😅

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Thanks for the idea!

  • @istvandarvas3372
    @istvandarvas33723 жыл бұрын

    Hi! This was an awesome tutorial, thanks! Let me allow to say something: because you are going to wait for only one result you don't need the "for" block starting in L41 only the "select" block, and I also think you cannot reach the L50 so you can remove / simplify that too or it would be even better to use a break in the select happy flow, and return from the end of the func

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Hi Istvan I am glad you liked the tutorial! This is by no means a production ready or pre-emptively scripted code, so it's improvised and used as showcase to run through and explain the Golang context concepts. I hope to make more time to prepare cleaner and more production ready examples in advance in the future! Thanks

  • @SuperShank76
    @SuperShank76 Жыл бұрын

    I think the latency logic should be: latency := rand.Intn(maxLatency - minLatency + 1) + minLatency (not - minLatency). Otherwise, latency could end up being negative.

  • @andreisorescu5389
    @andreisorescu53893 жыл бұрын

    Great explanation, thank you! Do we really need to wrap the select statement in the Search function in a for? Removed it & it seems to work fine, am I missing a special case?

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Thanks Andrei! Yes you can remove the for loop! In this case the select is blocking and any option will exit the function anyways. That's a mistake I made due to the fact that most times we have more than one event coming from the res channel, using the loop allows us to capture more than one event (like a stream of events coming from the channel)

  • @RN-er7mz
    @RN-er7mz3 жыл бұрын

    Thanks a lot

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Most welcome!

  • @a_maxed_out_handle_of_30_chars
    @a_maxed_out_handle_of_30_chars Жыл бұрын

    please someone correct me if this is wrong, we're waiting to receive interrupt/sigterm signal in the main function through a channel, when we receive it, the program exits and everything is fine but what if we don't receive the interrupt signal? the program will end as we're not synchronizing the interrupt channel with main function and if we had used wait group then the main function would wait until we receive an interrupt?

  • @evans8245
    @evans82453 жыл бұрын

    can i recommend a great way to customize your neovim coc: conquer of completion vim-plug: installer of neovim packages you won't regret it

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Thanks for the suggestion!

  • @CrashOverride332
    @CrashOverride3323 жыл бұрын

    This is ok, but vim is really not something you should do a tutorial video in. Having the text disappear every time you need to use the go run command makes it hard to follow.

  • @GolangCafe

    @GolangCafe

    3 жыл бұрын

    Hi TuskegeeHeir thanks for the feedback - I will make sure to adjust the format so that it's easier to follow!

  • @a_maxed_out_handle_of_30_chars

    @a_maxed_out_handle_of_30_chars

    2 жыл бұрын

    yes this is an issue but in newer videos he's using tmux which is lot better