Тёмный

Golang Context Explained - How To Use With Timeout 

Melkey
Подписаться 28 тыс.
Просмотров 16 тыс.
50% 1

🔍 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

Наука

Опубликовано:

 

25 сен 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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 5 месяцев назад
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
@Urgleflogue
@Urgleflogue 2 месяца назад
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 Месяц назад
Could you provide an example? This is what I'm trying to do right now and struggling
@Urgleflogue
@Urgleflogue Месяц назад
@@ashleyspianoprogress1341 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-kaZOXRqFPCw.html
@devfortunato
@devfortunato 28 дней назад
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.
@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!
@emil_l889
@emil_l889 8 месяцев назад
Context is really cool actually, good stuff
@wsollers1
@wsollers1 7 месяцев назад
Nice video. Simple to the point
@JohnBrosan
@JohnBrosan 8 месяцев назад
Great video! Any chance you can provide something on Authentication/Authorization with Go? Thanks!
@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.
@rosehogenson1398
@rosehogenson1398 8 месяцев назад
Great examples as always, Melkey
@a_storyy_teller
@a_storyy_teller 4 месяца назад
your explanation is awesome bro
@MelkeyDev
@MelkeyDev 4 месяца назад
Thank you so much 😀
@notoriouslycuriouswombat
@notoriouslycuriouswombat 8 месяцев назад
MELKEY MELKEY MELKEY
@sjc5
@sjc5 3 месяца назад
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 3 месяца назад
Thanks for the feedback - Will do this for my next tutorial :)
@emil_l889
@emil_l889 8 месяцев назад
Only context go needs is enums, sadge
@ronny584
@ronny584 3 месяца назад
A video that is 8 minutes long with a trash thumbnail, ends up with a trash example. This channel is cooked lmao.
@johnpeterson8493
@johnpeterson8493 8 месяцев назад
how far are you in Berserk?
@MelkeyDev
@MelkeyDev 7 месяцев назад
All caught up again
@emil_l889
@emil_l889 8 месяцев назад
Used my actual userID😮
@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 8 дней назад
this is not it. your time.Sleep() is blocking
Далее
How To Use The Context Package In Golang?
17:03
Просмотров 51 тыс.
This Is The BEST Way To Structure Your GO Projects
11:08
Pros vs Cons of When to USE Pointers in Golang
7:53
HTMX & Go with ThePrimeagen | Preview
15:58
Просмотров 144 тыс.
How the Golang Context Package Works
12:12
Просмотров 3,3 тыс.
My Initial Impresson Of Go
12:39
Просмотров 62 тыс.
Understanding Contexts in Go in 5(-ish?) Minutes
15:14
Advanced Golang: Limiting Goroutines
7:31
Просмотров 25 тыс.
Apple watch hidden camera
0:34
Просмотров 52 млн