Understanding Contexts in Go in 5(-ish?) Minutes

  Рет қаралды 59,381

TutorialEdge

TutorialEdge

2 жыл бұрын

👨‍💻 For the price of $7.99 every month, sign up and gain access to a growing list of premium courses on my site - tutorialedge.net/pricing/
Welcome Gophers, in this video, we'll be covering the topic of contexts within Go and how you an use them to propagate key/values through your application and also to handle things like timeouts. If you prefer, the original text version of this article can be found here - tutorialedge.net/golang/go-co...
✅ Subscribe and hit that 🔔 to get notified for all the latest tutorials!
🤓 / elliot_f
‎💻 tutorialedge.net
🎥 Recording Setup
Microphone - amzn.to/3hvASys
Mic Boom - amzn.to/3o0cW8Q
Mouse - amzn.to/2WZMoZs
Monitor 1 - amzn.to/38IUlYy
Monitor 2 - amzn.to/3rBTZf7
Mount - amzn.to/3o3185V
USB-C Hub - amzn.to/3o2xRbw

Пікірлер: 37
@eduardozepeda1972
@eduardozepeda1972 Жыл бұрын
I searched for tutorials about go's context and yours was the only one I understood. Thank you so much.
@adedoyinphilip8647
@adedoyinphilip8647 Жыл бұрын
Thank you for this. Quite explanatory! 🙏
@fuadadio
@fuadadio 2 ай бұрын
Finally understood this concept. Thank you so much.
@m_205
@m_205 Жыл бұрын
It's very helpful. Thank you so much for the effort.
@feynmaz
@feynmaz Жыл бұрын
Thank You. The tutorial is great!
@KoltPenny
@KoltPenny Жыл бұрын
I want my $0.00001 from the ads back 😆. Great video, keep it up.
@gonzariosm
@gonzariosm 2 жыл бұрын
Great example, thanks a lot for the info :D
@kumar-jatin-2000
@kumar-jatin-2000 5 ай бұрын
Really well made video. Thank you.
@keivinc
@keivinc Жыл бұрын
thank you for the very good explanation 😀
@michaeldausmann6066
@michaeldausmann6066 2 жыл бұрын
good explanation. thanks.
@TomDoesTech
@TomDoesTech 2 жыл бұрын
So early it's still in 360p :) Great video!
@giridharanpasupathi
@giridharanpasupathi Жыл бұрын
Good explanation bro... ✔️
@cariyaputta
@cariyaputta 2 жыл бұрын
Would you please cover the case of context use with grpc? Like how does the grpc lib make use of context, or how to use it for auth ...
@zawkhaled
@zawkhaled 2 жыл бұрын
Definitely removed some of the confusion!
@kevinkkirimii
@kevinkkirimii 5 ай бұрын
A question 10:40 is there need for the select case at line 35 since ctx.done() blocks and will be invoked once the timeout has exceeded ?!
@Nuraddinhassan
@Nuraddinhassan 5 ай бұрын
your are my friend make my love golang, you are really great teacher, 😇🙂
@PeterNunnOZ
@PeterNunnOZ 2 жыл бұрын
Good explination.
@Tutorialedge
@Tutorialedge 2 жыл бұрын
Thank you Peter! I hope you are keeping well!
@HasanAYousef
@HasanAYousef 2 жыл бұрын
Great and simple, a side question, what is the theme you are using at VS code?
@clearlyajit
@clearlyajit 2 жыл бұрын
cobalt2 by wes bos
@nsevalkar
@nsevalkar Жыл бұрын
Can you share your emacs config?
@garryhall9652
@garryhall9652 2 жыл бұрын
something that caused a little bit of confusion to me: the `
@adamburgess7890
@adamburgess7890 11 ай бұрын
Yeah this is no need for a select here :)
@DiegoGago
@DiegoGago 2 жыл бұрын
I've always wondered if sending information or adding logic via context is not a kind of hidden dependency in my code. Some people consider it a bad practice.
@klarnorbert
@klarnorbert 2 жыл бұрын
It is, and it shouldn't be used at all, according to Google.
@amitabhojha6117
@amitabhojha6117 2 жыл бұрын
​@@klarnorbert A citation would be great.
@pb8655
@pb8655 Жыл бұрын
Wouldn’t it make sense to pass context by pointer?
@pb8655
@pb8655 Жыл бұрын
If go is copying by value, shouldn’t ctx.done lose reference to the outer scope
@TechEats
@TechEats 2 жыл бұрын
This audio is not clear. would be great if you can add subtitles
@mwnkt
@mwnkt Жыл бұрын
i kinda understand context. though still not so clear.
@davidjdriver
@davidjdriver 6 ай бұрын
This is one part of go I really don't get. It hides dependencies inside a super parameter. If your method needs to know something it should be explicit or in scope of the struct as a base config. Putting values into a dictionary and passing the dictionary around hides the dependency. I don't understand how this became used in Go at all as it is actually an anti-pattern.
@Tutorialedge
@Tutorialedge 6 ай бұрын
I think there's a bit of a misunderstanding about the intent of context.Context here. You absolutely should not use it for things that are needed by the function, but the context may be used to pass extraneous information such as the request_id or trace_id that's currently being handled so that you can enrich logs/traces without polluting your function's logic and making it overly complex. If there are hard dependencies needed by your functions or methods, then these should be either passed in, or set on the struct that the method hangs off of.
@sorrowseal
@sorrowseal 2 жыл бұрын
Video is only 360p, too blurry.
@sorrowseal
@sorrowseal 2 жыл бұрын
All good now, youtube took longer than it used to.
@user-zj8dp8ue1z
@user-zj8dp8ue1z 2 жыл бұрын
広めてください」、
@susiebaka3388
@susiebaka3388 Жыл бұрын
it took you 8 minutes to get to the context interface despite this being a tutorial on contexts in Go ...
@elgs1980
@elgs1980 2 жыл бұрын
I don't think this should be part of the Go language.
Getting Started with Generics in Go
13:12
TutorialEdge
Рет қаралды 27 М.
How To Use The Context Package In Golang?
17:03
Anthony GG
Рет қаралды 55 М.
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 49 МЛН
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 25 МЛН
Advanced Golang: Channels, Context and Interfaces Explained
22:17
Code With Ryan
Рет қаралды 112 М.
Beginner's Guide to Redis with Go!
11:27
TutorialEdge
Рет қаралды 4,6 М.
Tutorial: Do you really think you understand Go interfaces?
11:38
Learn Go Programming
Рет қаралды 64 М.
Concurrency in Go
18:40
Jake Wright
Рет қаралды 608 М.
Golang Context Explained - How To Use With Timeout
8:22
Melkey
Рет қаралды 17 М.
Understanding Allocations: the Stack and the Heap - GopherCon SG 2019
21:39
How the Golang Context Package Works
12:12
Tiago
Рет қаралды 4,1 М.
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27