justforfunc #9: The Context Package

  Рет қаралды 143,365

justforfunc: Programming in Go

justforfunc: Programming in Go

Күн бұрын

Пікірлер: 159
@rfgraham85
@rfgraham85 7 жыл бұрын
5 minutes into the video and you've made more sense than the last 10 videos I've watched around Go concepts. Incredible approach to teaching while covering real world scenarios. Amazong job. Subbed!
@edwingarcia5043
@edwingarcia5043 3 жыл бұрын
What makes you think that the other videos didn't help you to get ready for watching this one video? 🤔
@johnryan6020
@johnryan6020 2 жыл бұрын
@@edwingarcia5043 That happens too, doesn't it. Great point (if not misplaced)! Most likely, it doesn't materially negate the effectiveness of Francesc's approach. It's a vector field and Rob seemed to clearly be using a short-hand to say, "damn, this vector has a magnitude and direction that helped me."
@ogreeni
@ogreeni Жыл бұрын
I’ve been learning go for less than a week, and just encountered your channel. Sad to see you no longer upload, these videos are really good.
@davudsafarli5356
@davudsafarli5356 4 жыл бұрын
Thank you! I don't understand why no one starts by giving simple example like you do
@ozerbdy
@ozerbdy 6 жыл бұрын
Very clear explanation, with mental leaps just at the right times. And also blending the real world use cases into the examples is very well thought of. Thank you!
@JustForFunc
@JustForFunc 6 жыл бұрын
Wow, that's such a nice thing to say! Thanks 😊
@Filhodanuvem
@Filhodanuvem 3 жыл бұрын
From time to time I come back here and watch a random video. It inspires me so much. Thank you.
@RamiAwar
@RamiAwar 2 жыл бұрын
I love the preaching of good practices like not using the context to pass values unless absolutely necessary. This aligns with how I like to write code, even though I've seen other developers use context to pass non-request scoped data. This channel seems to be a hidden gem!
@RamiAwar
@RamiAwar 2 жыл бұрын
Kind of got scared by the video length at first though, glad I watched it anyways.
@derdere7803
@derdere7803 Жыл бұрын
I keep coming back to this video over time. It has a lot of value. Thanks for taking time and doing that. Where are you by the way, get back here and produce some more please.
@yeboahnanaosei
@yeboahnanaosei 4 жыл бұрын
This video is my go to reference material on go's contexts. Thank you very much
@alfaex.
@alfaex. 6 жыл бұрын
i read a lot of posts on medium and the GO blog about context and i was completely lost... with this video it was very easy to understand. Amazing job
@YBWang-pi9qq
@YBWang-pi9qq 3 жыл бұрын
Amazing explanations with examples. One of the most talent instructors. Thanks you and keep doing it.
@UnknownStuff0417
@UnknownStuff0417 4 жыл бұрын
Great video. A very important concept for setting up and handling things like timeouts and even exceptions in Go. I don't see this being addressed in other Go overview sites/videos. Really happy to come accross this. However, perhaps its just me but I don't think the last point/topic on sending value between "client.go" and "server.go" had appropriate phrasing from @justforfunc. I get his explanation for "foo" id to properly show up, the client has to include it as a header/body/uri-id as they are purely HTTP request data/communication. But that has nothing to do with inherently Go or even "context". I sort of interpreted this context as some internal "Go" communication between the client.go and server.go processes. And really the context in both client.go and server.go are between the those process' and operating system, but something like an HTTP client and server are really good examples to show where "context" is very applicable. Really good video but slightly misleading.
@willhawkins7391
@willhawkins7391 6 жыл бұрын
Francesc, I know this is an old Just for Func but I went back and watched it today and wanted to say Thanks! Great episode. As others have said, the explanation is perfect! Just what I needed. Thanks again and keep up the great work!
@mattmarshall1834
@mattmarshall1834 3 жыл бұрын
Great video. I'd been reading about context this afternoon and this very much tied up some mental loose ends I still had.
@daveteare1960
@daveteare1960 7 жыл бұрын
I really enjoyed this episode - thank you! I've seen context used a lot and never really understood it until now. ❤️
@mohsanabbas6835
@mohsanabbas6835 3 жыл бұрын
Best video on the topic. Thanks
@vbcv1
@vbcv1 5 жыл бұрын
I wonder how many developers would recognise "modern bear" t-shirt. Thanks for fueling up my desire to learn Go! Woof 😋
@juliankandlhofer7553
@juliankandlhofer7553 4 жыл бұрын
Great video! I watched 2 talkes before and was more confused about contexts after watching them. this video explained everything!
@MiguelAngelLastYear
@MiguelAngelLastYear 7 жыл бұрын
Priceless, as always. What about an episode about how to create applications that work at the same time on multiple servers, as a cluster? The guides I have seen are ambiguous and do not share the good practices they proclaim. That, or an episode about when it is recommendable to create gorutines and when not. Thank you, Francesc!
@JustForFunc
@JustForFunc 7 жыл бұрын
+Miguel Ángel Jimeno Arce can you give an example? Do you mean something like a cluster database?
@MiguelAngelLastYear
@MiguelAngelLastYear 7 жыл бұрын
JustForFunc yeah, a cluster database, a load balancer, a proxy to redirect http traffic, or a massive scanner which distributes traffic between available servers (my original idea was something pretty similar to this) and when it finalizes, joins results. Thank you!
@EnginDumlu
@EnginDumlu 7 жыл бұрын
Thanks Frances, was a clear explanation. Can you please do the next episode about package initialization, sharing variables (like db / session) around between packages?
@newshatavakoli5960
@newshatavakoli5960 3 жыл бұрын
Thanks for the great video. This video was just the right speed and amount of explanation that I needed, very to the point. Watching you code through the examples, I learned things other than the context package too.
@markmcdonnell
@markmcdonnell 7 жыл бұрын
thanks Frances, the quality of this video and its contents is exceptional :-)
@raam_sevak
@raam_sevak 6 жыл бұрын
I kept trying sending value with a context over the http to another machine, I stopped after I watched this video. Very detailed! I love your videos :D
@notangryjustdismayed
@notangryjustdismayed 7 жыл бұрын
very timely upload. was just playing around with this today and i wasn't quite sure if i was using it properly. thank you!
@JustForFunc
@JustForFunc 7 жыл бұрын
I hope it will help you! Feel free to ask any questions at the end :-)
@notangryjustdismayed
@notangryjustdismayed 7 жыл бұрын
thanks, this was a great video! one question i still have is this: i see a lot of talk about not storing contexts anywhere, and only passing contexts around as parameters. i don't have a problem with this, but i wonder why this is so important? what would be some of the unintended consequences of a struct holding a reference to a context? does the same rule apply to cancellation functions? (ok that was more than one question. i'm sorry) cheers!
@pm71241
@pm71241 7 жыл бұрын
I was a little puzzled by your suggestion to not use Context values to store information which affects program flow. I mean... I understand the argument, but I fail to see the alternative for HTTP middleware. First, sure, it's a given that it should only be used for request-scoped values and request-id is a prime example. But you recommended to pass request scoped values which affected program flow as parameters. That is of course in general correct for any code, but for HTTP middleware you are kinda stuck with the http.Handler interface (reponsewriter, request). So how would you pass, say, "user id" to a handler you wrap around without creating your own alternative to http.Handler and making your code less composable?
@chimmychingo6703
@chimmychingo6703 2 жыл бұрын
Loved this video. Watched a few that didnt quite get through, but this really brought into the right “context” xD
@DineshGowda24
@DineshGowda24 4 жыл бұрын
Thank you for this, this is amazing. I have read about context package, but couldn't really understand. But this 36 mins have been priceless. Very well done.
@xcvsdxvsx
@xcvsdxvsx 4 жыл бұрын
Thanks so much! 7 minutes in and I now understand what the code does that I was trying to decipher.
@aguiwang7876
@aguiwang7876 2 жыл бұрын
I am big fan from China who watch your video every day before sleep! 😀
@vishalsh1624
@vishalsh1624 2 жыл бұрын
Amazing explanation with real world examples. Thank you so much!
@ZenMonkIlya
@ZenMonkIlya 2 жыл бұрын
Excellent explanation. This is very helpful. Thank you!
@luvpranay
@luvpranay 3 жыл бұрын
Learning Golang from Bayer Mayfield. The best
@tomah911
@tomah911 6 жыл бұрын
I'm so glad I found your KZbin channel ! This video is perfect to understand how to use the Context package, thx !
@sergeywhite8897
@sergeywhite8897 4 жыл бұрын
Thank you, you're REALLY doing well. Thank you one more time!!!
@Ysonichero
@Ysonichero 4 жыл бұрын
Thank you Frances, it’s really help me to understand context package.
@faroukfaiz8396
@faroukfaiz8396 2 жыл бұрын
This is some good quality content!
@AbdulMannan-rv5yx
@AbdulMannan-rv5yx 3 жыл бұрын
Really nice, clear my head lots on this package
@unknownknowns420
@unknownknowns420 2 жыл бұрын
phenomenal explanation, thanks!
@matheusaraujo4495
@matheusaraujo4495 2 жыл бұрын
Very nice explanation! Thanks
@darrensapalo
@darrensapalo 3 жыл бұрын
Incredible talk.
@codesworth
@codesworth 7 жыл бұрын
This helped me understand the context package much better, thank you!
@kamal-xd7id
@kamal-xd7id 7 жыл бұрын
Do you have any other example for context with value other than request id? It would be better to understand this concept if you can. Thanks!
@adnanrashid6743
@adnanrashid6743 4 жыл бұрын
Really enjoyed the explanation, very clear 👍🏽
@tanoybhowmick8715
@tanoybhowmick8715 4 жыл бұрын
Please keep the good work up. So good.
@MD-xx6ob
@MD-xx6ob 6 жыл бұрын
You've done a great job ! You're accent is very clear for a frenchie like me
@JustForFunc
@JustForFunc 6 жыл бұрын
Merci beaucoup, je fais mon mieux
@OfferoC
@OfferoC 7 жыл бұрын
Nice vscode setup. Can you describe the exact set up somewhere in a post or video?
@publicuser993
@publicuser993 4 жыл бұрын
That's what i needed. BIG THANK YOU
@alesresta
@alesresta 7 жыл бұрын
I've been learning so much watching your videos! Thank you very much.
@Alfrednohike9909
@Alfrednohike9909 Жыл бұрын
Hi, I would love to hear from you, as someone with a lot of experience in Golang, do you think SOLID Principles important in practice, and in interviews? Would I be asked a lot of questions, and how would I go about that, considering that SOLID Principles are mostly OOP concepts, and Golang is not a real OOP language. I am also curious about the same for design patterns like Builder, Factory pattern etc
@davidagyakwa288
@davidagyakwa288 3 жыл бұрын
Deep dive in context ...id be glad
@vs4vijay
@vs4vijay 4 жыл бұрын
One of the best explanation!!! Thanks.
@susisorglos3215
@susisorglos3215 7 жыл бұрын
Hey, very nice video! Could you make an episode about you vscode setup and the extensions you are using? Thanks!
@mehditorkamani9890
@mehditorkamani9890 5 жыл бұрын
Amazing... Short and sweet!
@paragkamble
@paragkamble 3 жыл бұрын
Thanks Very clear explanation.
@GertCuykens
@GertCuykens 7 жыл бұрын
Nice, learnt allot. PS can you also give the reason behind values not propagating like cancel please?
@jayeshthamke7860
@jayeshthamke7860 4 жыл бұрын
Exceptional work!
@lhpegz
@lhpegz Жыл бұрын
lets say about following the trace-id and span-id, both are probably good values for contexts right?
@mehradsadeghi
@mehradsadeghi 3 жыл бұрын
Thank you for this video.
@keepondev
@keepondev 4 жыл бұрын
Amazing explanation! thank you so much
@ericnyamu5249
@ericnyamu5249 5 жыл бұрын
thanks Thor.I now understand Go better
@Jordan-kk5xj
@Jordan-kk5xj 2 жыл бұрын
Regarding the ability for the HTTP client to "cancel" the request via the context which notifies the HTTP server, I assume this would only work with such a golang client and a golang server, correct? I.e. this is impossible with say a Java client and golang server, correct?
@michalvyskocil
@michalvyskocil 5 жыл бұрын
Hi, amazing stuff! I was still struggling on how to use context skimming the official docs. However this is simply awesome. Especially thanks for showing that you can't send context values across network.That would be stupid idea anyway :-)
@john_rambo_27098
@john_rambo_27098 6 жыл бұрын
Beautiful, Excellent, Mind Blowing, Priceless
@nwjlions
@nwjlions 7 жыл бұрын
Really informative video. Thanks Francesc.
@DreammzShow
@DreammzShow 4 жыл бұрын
Thank you for the great videos. This is really helpful.
@phillippotter1359
@phillippotter1359 4 жыл бұрын
Really helpful video, thank you dude, keep up the great work!
@kamal-xd7id
@kamal-xd7id 7 жыл бұрын
Learned Context in one go, without even pausing a single sec. :) btw which editor you are using and i saw you have some template like hand -> f(w http.Responsewrite, r *http.Request), how to do it?
@ericb.9777
@ericb.9777 7 жыл бұрын
Very clear, as always, GO on
@dmytro.tsapko
@dmytro.tsapko 7 жыл бұрын
Hi, looks like using context.WithTimeout somehow tears down TCP half-connection from client to server, that's why you got context closed on the server side. I didn't get how it closes the half-connection. But the question is why context.WithCancel does not tear down TCP half-connection after invoking cancel() ?
@chevs11
@chevs11 3 жыл бұрын
That was very useful, thanks!
@Oswee
@Oswee 6 жыл бұрын
I really, really, really would like to see complete series about how to create IDIOMATIC Client Server WEB application with most common CRUD operations using gRPC and MySQL. Client and Server should be just simple Go programs. Would like to see: IDIOMATIC Directory/File organization in context of github.com/myusername/. gRPC service interface, and message/+field idiomatic naming and organizing into packages. Package +nested package importing. Compiling nested .proto's. TLS secured gRPC communication. Idiomatic endpoint URL constructions. Context. Displaying in browser - single record, list of records, single record + list. Submitting form, updating record, creating nested records - like, when customer is created, also some log record in the same DB is created pointing to the same customer (tx). And so on so on. Basically, EVERY beginner want to see complete IDIOMATIC example of writing production ready basic DD web-page. Nobody is teaching this. 98% of tutorials and books teaching the easiest way - Just mess everything into main.go and use mock data! This is total BS! This is not how good things should be teached. It is much better when you see, how great foundation looks like and then starting to tweak, and to learn all those used patterns in details. When you have no context in head, it is impossible to learn right way. Iterating thru the trial & fail is way to learn for sure, but it is not the most effective! It just wastes too much human time. YES - this kind of tutorial will take time to record. But this will be the SINGLE PERFECT TUTORIAL in the whole f*g WEB.
@sweetmoment8196
@sweetmoment8196 5 жыл бұрын
Just one word, Awesome
@bathaivan4323
@bathaivan4323 4 жыл бұрын
very helpful, thanks very much
@jojoross
@jojoross 4 жыл бұрын
useing a function (sllepAndTalk) you created for half of the video ,and not showing how that function worked was a waste of my time. thank you for frustrating me back to the doc.
@johnbalvin5401
@johnbalvin5401 6 жыл бұрын
how do I set up visual studio to add the package library while I writting code? I always need to do it for myself and is anoying
@AlexTitarenko87
@AlexTitarenko87 6 жыл бұрын
excellent explanation
@nolliepoper
@nolliepoper 7 жыл бұрын
This was super helpful, thank you.
@AnhNguyen-vu7mc
@AnhNguyen-vu7mc 7 жыл бұрын
Hey Francesco, huge thanks for your series of videos. was wondering if you can post the code repo on github
@JustForFunc
@JustForFunc 7 жыл бұрын
+Anh Nguyen it's on GitHub.com/campoy/justforfunc
@trompelek
@trompelek 3 жыл бұрын
like your tee!
@kauehmoreno8967
@kauehmoreno8967 5 жыл бұрын
I got a doubt. When u write a handler with select case, context will be cancel only because your time.After are holding execution and than
@kauehmoreno8967
@kauehmoreno8967 5 жыл бұрын
I got it!! It will be able to run on a different goroutine returning value and catch it into select statement
@MrGreen-kq4ds
@MrGreen-kq4ds 4 жыл бұрын
amazing video , thank you!
@grantseltzerrichman2051
@grantseltzerrichman2051 7 жыл бұрын
This was great, thanks so much!
@JohnHAdams-vo2pk
@JohnHAdams-vo2pk 4 жыл бұрын
Awesome!!!
@polypus74
@polypus74 4 жыл бұрын
13:48 hallelujah!!!
@sphaniy
@sphaniy 6 жыл бұрын
Francesc, Did you do the episode on the internals of the context package?
@JustForFunc
@JustForFunc 6 жыл бұрын
Yup, literally the episode after this one
@SergeySaraev-xe4fl
@SergeySaraev-xe4fl 7 жыл бұрын
Very Nice! Thatk you Francesc!
@ffridiejr
@ffridiejr 7 жыл бұрын
Very helpful. Thanks.
@pnsvinodkumar
@pnsvinodkumar 5 жыл бұрын
super awesome!
@capnnukasun810
@capnnukasun810 4 жыл бұрын
thanks! really helped (at work)
@jjrumi
@jjrumi 7 жыл бұрын
T-h-a-n-k y-o-u. ------------------------- I was really going to send you a message requesting exactly this :) Love your channel so far. Keep it up!!!!
@sayansikdar4385
@sayansikdar4385 3 жыл бұрын
where can I find the codes which are written here?
@garciajero
@garciajero 6 жыл бұрын
this is so good.
@TylerShawful
@TylerShawful 3 жыл бұрын
That poor plant in the background needs water
@redsnakeintown
@redsnakeintown 6 жыл бұрын
Couldnt figure out what you did in the Decorate. I think I need some sleep..
@RandomShowerThoughts
@RandomShowerThoughts 5 жыл бұрын
it was basically a middle ware which adds in a request id into the context and returns the next function as a call
@Simon-xi8tb
@Simon-xi8tb 2 жыл бұрын
where is the sleepAndTalk fn ?
@ColmMalone
@ColmMalone 4 жыл бұрын
Who's here from the Aug 20th Go Time podcast? BTW at 21:00 - since go1.13 - you can now do this in one call with: golang.org/pkg/net/http/#NewRequestWithContext
@bargrz
@bargrz 5 жыл бұрын
Subtitles on: 'Hi! I am Franciscan boy!' :p
@Waffle-ish
@Waffle-ish 3 жыл бұрын
Disclaimer: kinda new to golang XD What do you mean by "defining a request without using tags?"
@kianyanglee4618
@kianyanglee4618 7 ай бұрын
What's the != symbol at @15:46? Shouldn't it be !=?
@SaxonChuang
@SaxonChuang 4 жыл бұрын
I have no idea about how the function sleepAndTalk know we cancelled
@KotBinary
@KotBinary 4 жыл бұрын
I had the same question. So, I googled this: gist.github.com/astenmies/2f180213d310aa16b4b8c4e637be9441
@SaxonChuang
@SaxonChuang 4 жыл бұрын
@@KotBinary thanks :)
@kewang1612
@kewang1612 7 жыл бұрын
I was following along typing in another window and 13:51 scared the xxxx out of me... :)
@jojjan93
@jojjan93 6 жыл бұрын
Great video francesca ;)
@JustForFunc
@JustForFunc 6 жыл бұрын
That's not my name
@jojjan93
@jojjan93 6 жыл бұрын
JustForFunc: Programming in Go hehe 😁
@jojjan93
@jojjan93 6 жыл бұрын
JustForFunc: Programming in Go i know, i just couldnt remember which video it was where at the end someone couldnt say your name :)
justforfunc #8: Flappy Gopher III - Collision detection
47:24
justforfunc: Programming in Go
Рет қаралды 10 М.
How To Use The Context Package In Golang?
17:03
Anthony GG
Рет қаралды 66 М.
Мама у нас строгая
00:20
VAVAN
Рет қаралды 10 МЛН
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 86 МЛН
The context package internals - Damiano Petrungaro
49:31
GopherCon UK
Рет қаралды 6 М.
This is the BEST Golang Context Package Tutorial
12:18
Melkey
Рет қаралды 14 М.
justforfunc #4: Code Review for a Twitter client
42:01
justforfunc: Programming in Go
Рет қаралды 20 М.
justforfunc #16: unit testing HTTP servers
48:31
justforfunc: Programming in Go
Рет қаралды 71 М.
Advanced Golang: Channels, Context and Interfaces Explained
22:17
Code With Ryan
Рет қаралды 125 М.
justforfunc #35: Implementing the tree command from scratch
30:54
justforfunc: Programming in Go
Рет қаралды 12 М.
justforfunc #10: implementing the context package
40:00
justforfunc: Programming in Go
Рет қаралды 23 М.
The standard library now has all you need for advanced routing in Go.
13:52