Golang Context Explained - How To Use With Timeout

  Рет қаралды 16,797

Melkey

Melkey

9 ай бұрын

🔍 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
Twitch : / melkey
Join the amazing community on Discord
Discord: / discord
I post memes and host Twitter Tech Spaces
Twitter: / melkeydev
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

Пікірлер: 32
@MelkeyDev
@MelkeyDev 8 ай бұрын
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!
@JohannesLuebke
@JohannesLuebke 6 ай бұрын
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?
@0xZeeS
@0xZeeS 8 ай бұрын
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!
@kartashuvit4971
@kartashuvit4971 8 ай бұрын
where would you error using the context in that case?
@tayyab0987
@tayyab0987 7 ай бұрын
@@kartashuvit4971 have a for loop checking for the error then kill the http request
@devfortunato
@devfortunato Ай бұрын
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.
@Urgleflogue
@Urgleflogue 3 ай бұрын
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.
@ashleyspianoprogress1341
@ashleyspianoprogress1341 2 ай бұрын
Could you provide an example? This is what I'm trying to do right now and struggling
@Urgleflogue
@Urgleflogue 2 ай бұрын
@@ashleyspianoprogress1341 kzbin.info/www/bejne/oZK9gIuIpquDedk
@wsollers1
@wsollers1 8 ай бұрын
Nice video. Simple to the point
@emil_l889
@emil_l889 8 ай бұрын
Context is really cool actually, good stuff
@JohnBrosan
@JohnBrosan 8 ай бұрын
Great video! Any chance you can provide something on Authentication/Authorization with Go? Thanks!
@a_storyy_teller
@a_storyy_teller 4 ай бұрын
your explanation is awesome bro
@MelkeyDev
@MelkeyDev 4 ай бұрын
Thank you so much 😀
@BanAaron
@BanAaron 8 ай бұрын
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
@Kane0123
@Kane0123 8 ай бұрын
Laptop speakers? Gotta get that upgraded player!
@rosehogenson1398
@rosehogenson1398 8 ай бұрын
Great examples as always, Melkey
@notoriouslycuriouswombat
@notoriouslycuriouswombat 8 ай бұрын
MELKEY MELKEY MELKEY
@rafaelacioly3252
@rafaelacioly3252 8 ай бұрын
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?
@hakooplayplay3212
@hakooplayplay3212 6 ай бұрын
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.
@emil_l889
@emil_l889 8 ай бұрын
Only context go needs is enums, sadge
@emil_l889
@emil_l889 8 ай бұрын
Used my actual userID😮
@sjc5
@sjc5 4 ай бұрын
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.
@MelkeyDev
@MelkeyDev 4 ай бұрын
Thanks for the feedback - Will do this for my next tutorial :)
@johnpeterson8493
@johnpeterson8493 8 ай бұрын
how far are you in Berserk?
@MelkeyDev
@MelkeyDev 8 ай бұрын
All caught up again
@ronny584
@ronny584 4 ай бұрын
A video that is 8 minutes long with a trash thumbnail, ends up with a trash example. This channel is cooked lmao.
@superkorki98
@superkorki98 8 ай бұрын
fix the audio pls
@thewhiteoaktree
@thewhiteoaktree 8 ай бұрын
How do I get the values of an associative array in PHP?
@bumpy_lumps
@bumpy_lumps 8 ай бұрын
i think it's in the go docs somewhere
@loohbiidloo4753
@loohbiidloo4753 8 ай бұрын
arr[“key” => “value”] $value = arr[“key”]
@jeffreysmith9837
@jeffreysmith9837 28 күн бұрын
this is not it. your time.Sleep() is blocking
How To Use The Context Package In Golang?
17:03
Anthony GG
Рет қаралды 53 М.
Advanced Golang: Channels, Context and Interfaces Explained
22:17
Code With Ryan
Рет қаралды 110 М.
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 55 МЛН
small vs big hoop #tiktok
00:12
Анастасия Тарасова
Рет қаралды 9 МЛН
This Is The BEST Way To Structure Your GO Projects
11:08
Melkey
Рет қаралды 62 М.
The BEST Tool to Deploy Your Apps (Stop using Vercel)
10:07
Understanding Contexts in Go in 5(-ish?) Minutes
15:14
TutorialEdge
Рет қаралды 58 М.
The TRUTH About Golang Backend Frameworks
6:31
Melkey
Рет қаралды 101 М.
My Initial Impresson Of Go
12:39
TheVimeagen
Рет қаралды 73 М.
Don't Use React Context!! Use This instead
13:34
CoderOne
Рет қаралды 26 М.
Go isn’t secure?!? feat. Low Level Learning | 053
51:14
Backend Banter
Рет қаралды 35 М.
How the Golang Context Package Works
12:12
Tiago
Рет қаралды 3,6 М.
Разряженный iPhone может больше Android
0:34
🔥Идеальный чехол для iPhone! 📱 #apple #iphone
0:36
Не шарю!
Рет қаралды 1,2 МЛН
Will the battery emit smoke if it rotates rapidly?
0:11
Meaningful Cartoons 183
Рет қаралды 24 МЛН
ТОП-5 культовых телефонов‼️
1:00
Pedant.ru
Рет қаралды 20 М.