Golang Context Explained - How To Use With Timeout

preview_player
Показать описание
🔍 If you're a Go developer looking to improve your understanding of context management and concurrency control, you're in the right place.

In this video, we break down the fundamentals of the Golang Context package, exploring its core concepts, practical applications, and best practices. Whether you're a beginner or an experienced Go developer, this tutorial has something valuable to offer.

### Twitch
I stream live on Twitch every weekend
Join the amazing community on Discord
I post memes and host Twitter Tech Spaces

SUBSCRIBE OR GET LAID OFF
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #neovim #typescript #programming #vim #softwareengineering #codinglife #webdesign #webdevelopment #webdev #javascript #rustlang #rust #twitch #twitchstreamer #programmerhumor #codinghumor #software #softwareengineer #softwaredeveloper #softwaredevelopment #gymbro #gym #programmerhumor #programming #coding #golang #go #goprogramming
Рекомендации по теме
Комментарии
Автор

I hope you all loved this video! Leave a like, comment, like + subscribe. It means the world to me. Let me know what video you want to see in the future!

MelkeyDev
Автор

You should put the long call in a goroutine with a loop and switch. What you've done here is not what contexts are for, you could've just measure the elapsed time and return error or otherwise.

Urgleflogue
Автор

A video that is 8 minutes long with a trash thumbnail, ends up with a trash example. This channel is cooked lmao.

ronny
Автор

But are we still waiting for 400ms? We are just not returning the result but an error right? Or how do we reach the ctx.Err() check before the 400ms run out?

JohannesLuebke
Автор

Great video!
However, example could be better - since the function still blocks until the time it takes for the API call. I.e. if API call blocked for an hour, you'd need to wait for the whole hour, only to encounter deadline exceeded error.
^ Nevertheless, this vid presents a good starting point!

xZeeS
Автор

You should have used a goroutine with a select statement and check the ctx.Done() or the result. What are you doing in the example is just waiting for the result and throwing away if the time is exceed.

devfortunato
Автор

Could you boost the audio levels on your videos? I have to have my laptop speakers at 100% to be able to hear clearly, it is only with your videos

BanAaron
Автор

If the func in sleeping for 400ms (didn't reach the if statement) and the context is cancelled, how the "context timeout exceeded" error is reached?

rafaelacioly
Автор

Hi! What model of headphones do you use in this video? I'm searching for comfortable and good-sounding headphones and yours look quite promising. Great video by the way. Cheers!

GoWithAndy-cptz
Автор

Context is really cool actually, good stuff

emil_l
Автор

Thanks for the great content. It would be nice to have less jumping around between zoomed in text editor / your camera / split view. Just sticking to split view would be easier to watch / follow. Thanks again.

sjc
Автор

Only context go needs is enums, sadge

emil_l
Автор

Great video! Any chance you can provide something on Authentication/Authorization with Go? Thanks!

JohnBrosan
Автор

How do I get the values of an associative array in PHP?

thewhiteoaktree
Автор

this is not it. your time.Sleep() is blocking

jeffreysmith
Автор

It's wrong example the sleep call is blocking call so it will still wait and just return deadline error after waiting for sleep time so the whole purpose of using context is defeated @MelkeyDev should correct the video or atleast delete the video so that your viewers are not mis-guided

AnilGupta-vc