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!
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 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."
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!
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!
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.
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.
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!
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
Thanks Frances, was a clear explanation. Can you please do the next episode about package initialization, sharing variables (like db / session) around between packages?
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.
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 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!
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!
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?
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 :-)
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.
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!!!!
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() ?
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?
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?
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
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 ?
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.
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.