Тёмный

justforfunc #9: The Context Package 

justforfunc: Programming in Go
Подписаться 39 тыс.
Просмотров 139 тыс.
50% 1

Ask any questions on francesc
Do you know how to use the context package from Go's standard library?
Then get ready to learn how it can make your requests​ easier to monitor, your logs easier to grep, and your servers more efficient!

Наука

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

 

6 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 163   
@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 2 года назад
What makes you think that the other videos didn't help you to get ready for watching this one video? 🤔
@johnryan6020
@johnryan6020 Год назад
@@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.
@ozerbdy
@ozerbdy 5 лет назад
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 5 лет назад
Wow, that's such a nice thing to say! Thanks 😊
@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!
@daveteare1960
@daveteare1960 7 лет назад
I really enjoyed this episode - thank you! I've seen context used a lot and never really understood it until now. ❤️
@YBWang-pi9qq
@YBWang-pi9qq 3 года назад
Amazing explanations with examples. One of the most talent instructors. Thanks you and keep doing it.
@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
@markmcdonnell
@markmcdonnell 7 лет назад
thanks Frances, the quality of this video and its contents is exceptional :-)
@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.
@Filhodanuvem
@Filhodanuvem 3 года назад
From time to time I come back here and watch a random video. It inspires me so much. Thank you.
@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.
@tomah911
@tomah911 6 лет назад
I'm so glad I found your RU-vid channel ! This video is perfect to understand how to use the Context package, thx !
@juliankandlhofer7553
@juliankandlhofer7553 4 года назад
Great video! I watched 2 talkes before and was more confused about contexts after watching them. this video explained everything!
@davudsafarli5356
@davudsafarli5356 4 года назад
Thank you! I don't understand why no one starts by giving simple example like you do
@yeboahnanaosei
@yeboahnanaosei 3 года назад
This video is my go to reference material on go's contexts. Thank you very much
@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.
@alesresta
@alesresta 7 лет назад
I've been learning so much watching your videos! Thank you very much.
@vbcv1
@vbcv1 5 лет назад
I wonder how many developers would recognise "modern bear" t-shirt. Thanks for fueling up my desire to learn Go! Woof 😋
@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.
@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
@codesworth
@codesworth 7 лет назад
This helped me understand the context package much better, thank you!
@Ysonichero
@Ysonichero 4 года назад
Thank you Frances, it’s really help me to understand context package.
@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?
@mehditorkamani9890
@mehditorkamani9890 5 лет назад
Amazing... Short and sweet!
@vishalsh1624
@vishalsh1624 2 года назад
Amazing explanation with real world examples. Thank you so much!
@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.
@xcvsdxvsx
@xcvsdxvsx 3 года назад
Thanks so much! 7 minutes in and I now understand what the code does that I was trying to decipher.
@john_rambo_27098
@john_rambo_27098 6 лет назад
Beautiful, Excellent, Mind Blowing, Priceless
@chimmychingo6703
@chimmychingo6703 Год назад
Loved this video. Watched a few that didnt quite get through, but this really brought into the right “context” xD
@sergeywhite8897
@sergeywhite8897 4 года назад
Thank you, you're REALLY doing well. Thank you one more time!!!
@nwjlions
@nwjlions 7 лет назад
Really informative video. Thanks Francesc.
@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!
@AndrewMinkinGen1us2k
@AndrewMinkinGen1us2k 7 лет назад
Hey. Now I know more about context. I never thought that I have context in net/http package and it was a surprise for me. Thank you!
@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?
@ZenMonkIlya
@ZenMonkIlya 2 года назад
Excellent explanation. This is very helpful. Thank you!
@vs4vijay
@vs4vijay 4 года назад
One of the best explanation!!! Thanks.
@phillippotter1359
@phillippotter1359 4 года назад
Really helpful video, thank you dude, keep up the great work!
@adnanrashid6743
@adnanrashid6743 3 года назад
Really enjoyed the explanation, very clear 👍🏽
@jayeshthamke7860
@jayeshthamke7860 4 года назад
Exceptional work!
@mohsanabbas6835
@mohsanabbas6835 2 года назад
Best video on the topic. Thanks
@unknownknowns420
@unknownknowns420 Год назад
phenomenal explanation, thanks!
@AbdulMannan-rv5yx
@AbdulMannan-rv5yx 3 года назад
Really nice, clear my head lots on this package
@tanoybhowmick8715
@tanoybhowmick8715 3 года назад
Please keep the good work up. So good.
@faroukfaiz8396
@faroukfaiz8396 2 года назад
This is some good quality content!
@MD-xx6ob
@MD-xx6ob 5 лет назад
You've done a great job ! You're accent is very clear for a frenchie like me
@JustForFunc
@JustForFunc 5 лет назад
Merci beaucoup, je fais mon mieux
@ericb.9777
@ericb.9777 7 лет назад
Very clear, as always, GO on
@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 :-)
@publicuser993
@publicuser993 3 года назад
That's what i needed. BIG THANK YOU
@matheusaraujo4495
@matheusaraujo4495 2 года назад
Very nice explanation! Thanks
@DreammzShow
@DreammzShow 4 года назад
Thank you for the great videos. This is really helpful.
@grantseltzerrichman2051
@grantseltzerrichman2051 7 лет назад
This was great, thanks so much!
@darrensapalo
@darrensapalo 2 года назад
Incredible talk.
@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.
@keepondev
@keepondev 3 года назад
Amazing explanation! thank you so much
@nolliepoper
@nolliepoper 7 лет назад
This was super helpful, thank you.
@MrGreen-kq4ds
@MrGreen-kq4ds 4 года назад
amazing video , thank you!
@AlexTitarenko87
@AlexTitarenko87 6 лет назад
excellent explanation
@SergeySaraev-xe4fl
@SergeySaraev-xe4fl 7 лет назад
Very Nice! Thatk you Francesc!
@mehradsadeghi
@mehradsadeghi 3 года назад
Thank you for this video.
@paragkamble
@paragkamble 2 года назад
Thanks Very clear explanation.
@batu266
@batu266 3 года назад
Very helpful, thank you.
@aguiwang7876
@aguiwang7876 Год назад
I am big fan from China who watch your video every day before sleep! 😀
@garciajero
@garciajero 6 лет назад
this is so good.
@chernovsergey23
@chernovsergey23 3 года назад
That was very useful, thanks!
@ffridiejr
@ffridiejr 7 лет назад
Very helpful. Thanks.
@sweetmoment8196
@sweetmoment8196 4 года назад
Just one word, Awesome
@pnsvinodkumar
@pnsvinodkumar 5 лет назад
super awesome!
@JohnHAdams-vo2pk
@JohnHAdams-vo2pk 3 года назад
Awesome!!!
@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!
@bathaivan4323
@bathaivan4323 3 года назад
very helpful, thanks very much
@OfferoC
@OfferoC 7 лет назад
Nice vscode setup. Can you describe the exact set up somewhere in a post or video?
@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
@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!!!!
@dmytrotsapko3207
@dmytrotsapko3207 6 лет назад
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() ?
@davidagyakwa288
@davidagyakwa288 3 года назад
Deep dive in context ...id be glad
@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 :)
@trompelek
@trompelek 3 года назад
like your tee!
@capnnukasun810
@capnnukasun810 4 года назад
thanks! really helped (at work)
@susisorglos3215
@susisorglos3215 7 лет назад
Hey, very nice video! Could you make an episode about you vscode setup and the extensions you are using? Thanks!
@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?
@ericnyamu5249
@ericnyamu5249 4 года назад
thanks Thor.I now understand Go better
@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?
@luvpranay
@luvpranay 2 года назад
Learning Golang from Bayer Mayfield. The best
@lhpegz
@lhpegz Год назад
lets say about following the trace-id and span-id, both are probably good values for contexts right?
@stupidfilip23
@stupidfilip23 Год назад
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
@vishwa1581
@vishwa1581 2 года назад
Thanks.
@polypus74
@polypus74 4 года назад
13:48 hallelujah!!!
@GertCuykens
@GertCuykens 7 лет назад
Nice, learnt allot. PS can you also give the reason behind values not propagating like cancel please?
@shiyuwang
@shiyuwang 4 года назад
awesome
@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
@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
@umeshdhaked1703
@umeshdhaked1703 3 года назад
f awesome.
@AnhNguyen-vu7mc
@AnhNguyen-vu7mc 6 лет назад
Hey Francesco, huge thanks for your series of videos. was wondering if you can post the code repo on github
@JustForFunc
@JustForFunc 6 лет назад
+Anh Nguyen it's on GitHub.com/campoy/justforfunc
@bargrz
@bargrz 5 лет назад
Subtitles on: 'Hi! I am Franciscan boy!' :p
@easternsunking255
@easternsunking255 6 лет назад
what will happen if the both the parent routine and child routine cancel the context at the same time. and if the parent routine has more than one routine like Ca and Cb for example, both the Ca and Cb use the context from parent routine P, if the P cancelend, both Ca and Cb will canceled? if only Ca canceled, then P and Cb will not be notified ?
@JustForFunc
@JustForFunc 6 лет назад
Closing a channel doesn't notify a single receiver (unlike sending elements) instead it unlocks every goroutine blocked receiving from it
@easternsunking255
@easternsunking255 6 лет назад
many thanks,after watch your next episonde(implement the context), I got it!
@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.
@redsnakeintown
@redsnakeintown 5 лет назад
Couldnt figure out what you did in the Decorate. I think I need some sleep..
@RandomShowerThoughts
@RandomShowerThoughts 4 года назад
it was basically a middle ware which adds in a request id into the context and returns the next function as a call
@Danzlh
@Danzlh 4 года назад
gooooooooooood shit
@kewang1612
@kewang1612 7 лет назад
I was following along typing in another window and 13:51 scared the xxxx out of me... :)
@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.
Далее
justforfunc #16: unit testing HTTP servers
48:31
Просмотров 71 тыс.
İranda azərbaycanlı prezident seçilib
00:32
Просмотров 243 тыс.
skibidi toilet zombie universe 34 ( New Virus)
03:35
Просмотров 2,6 млн
Yeni Özbək Mahnisi Yoxsa Vefali Reqsi? 😍
00:36
Просмотров 2,1 млн
How To Use The Context Package In Golang?
17:03
Просмотров 54 тыс.
justforfunc #42: Intro to Go Modules and SemVer
31:47
The context package internals - Damiano Petrungaro
49:31
Go Tooling  in Action
41:51
Просмотров 115 тыс.
The Only Unbreakable Law
53:25
Просмотров 318 тыс.
JSON Parser 100% From Scratch in Haskell (only 111 lines)
1:50:07
How the Golang Context Package Works
12:12
Просмотров 4 тыс.
8 Design Patterns | Prime Reacts
22:10
Просмотров 390 тыс.
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00