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!
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.
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?
@@fyrofux You're supposed to wait for the result in a separate goroutine and there's a way to check whether the context finished earlier than the func call. That way you're not waiting for no reason. This example is just bad.
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!
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.
it actually not canceled and continue to work. its just throw result out, because its too late. So this example is trash :) you actually need to cancel this function call in mid air if time is exceeded, so you need to run it in gorutine and wait outside in select for result or ctx.Done(), to not wait for this call to return something in a minute for example to just throw it away.
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!
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
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.
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!
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.
Could you provide an example? This is what I'm trying to do right now and struggling
@@ashleyspianoprogress1341 th-cam.com/video/kaZOXRqFPCw/w-d-xo.html
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?
Great question. I thunk it should be pretty easy to reproduce and test
@@fyrofux You're supposed to wait for the result in a separate goroutine and there's a way to check whether the context finished earlier than the func call. That way you're not waiting for no reason. This example is just bad.
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!
where would you error using the context in that case?
@@kartashuvit4971 have a for loop checking for the error then kill the http request
A video that is 8 minutes long with a trash thumbnail, ends up with a trash example. This channel is cooked lmao.
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.
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?
it actually not canceled and continue to work. its just throw result out, because its too late. So this example is trash :) you actually need to cancel this function call in mid air if time is exceeded, so you need to run it in gorutine and wait outside in select for result or ctx.Done(), to not wait for this call to return something in a minute for example to just throw it away.
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
Laptop speakers? Gotta get that upgraded player!
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!
Context is really cool actually, good stuff
your explanation is awesome bro
Thank you so much 😀
Nice video. Simple to the point
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
I have another video where I explain Go Context and makes the correction
Great video! Any chance you can provide something on Authentication/Authorization with Go? Thanks!
Only context go needs is enums, sadge
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.
Thanks for the feedback - Will do this for my next tutorial :)
MELKEY MELKEY MELKEY
how far are you in Berserk?
All caught up again
How do I get the values of an associative array in PHP?
i think it's in the go docs somewhere
arr[“key” => “value”]
$value = arr[“key”]
Great examples as always, Melkey
fix the audio pls
Used my actual userID😮
dude I'm so jealous you can just code away at whim like that
major fomo and major jealousy
this is not it. your time.Sleep() is blocking