k3nn3dy commited on
Commit
0da4ee7
·
verified ·
1 Parent(s): a5f5b0d

Add Golang_for_Hackers_-_LDAP_Injector_-_Episode_04_-_Functional_Options_Pattern.jsonl

Browse files
Golang_for_Hackers_-_LDAP_Injector_-_Episode_04_-_Functional_Options_Pattern.jsonl ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"text": "What's going on, YouTube? This is Ipsac and welcome to episode three of the Golang for hacker series. And this episode's going to be all about the functional options pattern, which isn't unique to Golang, but it's used much more frequently in Go because Go lacks optional arguments, overloads, etc. And at first, it's going to seem like this is completely overcomplicating something simple. But in the long run, I'm sure it will help keep your code cleaner and more maintainable. The easiest comparison I can think of is the functional option pattern is like creating an arg parse for functions in your program. Because if you've ever tried to do args off just fine but then ends up being a big ball of spaghetti with all the if then statements that you have trying to um implement args. Anyways, let's just get started. I have copied", "start": 0.08, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
2
+ {"text": "part of the net HTTP implementation in out of the LDAP injector and made it its own project so we can just focus on the piece of code that's important. And then once we're done this, we'll go and add this into our LDAP injector. But the code I have here is relatively straightforward. We just have the definition of our net HP brute implementation like method, URL, username, expected status code, and headers. If you did my previous two episodes, this shouldn't be um new to you, right? And then we have the function where we're just um assigning the implementation so we can start using it. And then we have main. And this is where it differs. All I'm doing is um defining it and then printing out all the variables. Right? So if I do a gorun dot, we can see it's just going to print all this out. And if we started trying", "start": 44.96, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
3
+ {"text": "to use this, it becomes a bit cumbersome, right? Because we have all these arguments that we're passing in.", "start": 91.119, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
4
+ {"text": "And we don't know what's needed, what's optional, what's not. And also, it's only hard-coded to use the status code, right? This is just testing if a password is valid or not in the website.", "start": 96.96, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
5
+ {"text": "And we're identifying if it's valid just based upon the status code. But what if both invalid and valid password returned HTTP 200? And we wanted to look for a string on the page, right? Then we'd have to add a string up here so we can then define it, right? We could say like expected string. Um then we have to also add it here. So we can change this.", "start": 107.439, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
6
+ {"text": "Instead of status code, this is just a string and it's a string like this. And then when we go to use it, let's see, it's after the username. Um we don't want an expected string here. So we just kind of got to give it a blank value because there's no optional. And this really isn't intuitive, right? You could just pass in the whole object, but that's going to have its own set of issues, right? So, if we did uh let's delete all this and then we just pass in I'm going to do C for client. Doesn't really matter what that's called. Pass in this. And then let's just return C method like this.", "start": 130.239, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
7
+ {"text": "Uh C URL like this. There we go. And now we can get rid of all of this. And then we just pass in um this and then define each thing here.", "start": 168.68, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
8
+ {"text": "Right? So this does also works and then we do go run. And what this allows us to do is just have like optional arguments, right? Because we don't have to pass in every parameter. But the flip side is how do we do default options here, right? And this like will just become a bunch of if thens validating it, right?", "start": 187.0, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
9
+ {"text": "We'll put like if URL starts with HTTP, if the options in these HTTP verbs, there's just so many things that we'd put in this and it just becomes messy.", "start": 208.0, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
10
+ {"text": "It's also just like not intuitive to use a function this way, right? Because when I call this, I peek at the definition like, oh, I need this implementation. I go and look at the implementation. I'm like, huh, what what do I need with all these? Right? So, this is going to be where like the functional options pattern starts coming into play. The first thing I'm going to do is just um create a default, which isn't part of functional options pattern, but it's definitely going to be needed. So to do that, I'm going to first um make HT options more generic because I'm going to use this for other libraries like the fast HTTP one. So I'm just going to put all these options in a strct called HTTP ops. And then in our implementation we're just going to say that contains HTTP ops. Awesome. Um for this I'm just going to uh not pass in", "start": 217.12, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
11
+ {"text": "any arguments right now to keep it simple. And then we can say http ops is going to be equal to the default options. And we have to create that. So I'm going to create funk default ops. I probably should do like default HTTP ops to keep it all like in sync, but that's fine. The output of this is going to be the strruct HTTP ops. So we can just return this and I'm only going to do the get. So here the first thing we can do O is equal to default ops and then this is O right yeah uh where is it erroring hb ops I don't know why that's erroring net hb brute implementation what are you missing comma Okay, that's a simple enough error to fix. And then here in main, um, we're just not going to pass in any arguments here. And we're going to see we have just something with, uh, get, right? If we change the default to be not get,", "start": 270.639, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
12
+ {"text": "let's do um, please sub, then go run, we can see that's now please sub. So, let's put this back over to get. We can say the username, uh, the default username, let's always get admin. But that's it for the default options right now. So, what we want to do is be able to edit, um, all these options. And this is going to be where it gets a little bit more complicated because we're going to go into function type definitions and higher order functions. You have to understand exactly how all that works because a lot of this is just um, copy and pasting things, right? So, we're going to start off with the function type definition.", "start": 350.8, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
13
+ {"text": "So, that's going to be a type. I'm going to do HTTP opt funk and funk um http ops. So, what this is going to enable us to do is create a slice of functions that modify um our thing. And essentially, we're going to create a bunch of setters to set variables. So, we have that code.", "start": 390.479, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
14
+ {"text": "Now, what we need to do is create the higher order function. So that's going to be um let's start with with method.", "start": 411.759, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
15
+ {"text": "So we can do funk with method and then pass in the method that's like get postput delete and that's going to return a function. So since we're returning a function we'll do return funk and we're going to pass in our current HTTP options. So we'll do a pointer to hpops and then we're just going to set it. So we'll do ops method. Uh that's not method. Ops do method is equal to method. Awesome. So now over in this new brute implementation, I'm going to do a I think it's a verdeic something. Um but essentially you do three dots and then we can say um what we want to pass in and that was I think an HTTP option function. And now we have the um HP options here. So we're going to loop over all the functions we passed in here. So that's going to be for function range ops. And then we can say that function point give it the pointer to", "start": 418.88, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
16
+ {"text": "our options and that should let us set it. So if you understand this pretty much everything's done. This is all downhill from here. If you don't understand it, hopefully after you um do it a few times, it starts making sense.", "start": 489.68, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
17
+ {"text": "You can always leave comments. I try to respond and help people out. But now in this function, we can say with method and then I'm going to change this to post, right? And I'm going to put this on a new line. I think that's just easier to read. Go run. And now method is post. We can change that to um if go run method is it. So this is pretty much it. And this helps code so much. And I know the video is pretty much just getting started, but we're going to go add these options for everything else because there's a few like um catches, right? Uh the first few are going to be easy. So we can do like funk with um let's see, I'm going to do a expect here. So, we'll do expected string. And then, um, what do I want to call the string?", "start": 503.199, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
18
+ {"text": "Uh, expected string is a string. And that's also going to be pretty much the same thing. And we can do funk expected status code. And then let um, co-pilot finish it off. So, that's that. So, we have string status code. Uh, let's do username real quick because this is also the same thing. We can do funk with username and then finish that off. So if we look at this method, we can do a go run. We only have post the username was admin. So we can change this to be with username and then we can say run it. Go run. You can see the username changed. The status code is currently zero. We can do a um with Oh, we did expected. So expected status code is equal to uh this is an integer so 200 run this and we have that there. So everything is behaving to plan. Now when we get into the header it's going to", "start": 555.32, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
19
+ {"text": "change slightly um but not that much. So we can do funk um with header and then like that. So, we're taking in the header and the value. And what's different here is because we have this map here, if this map isn't initialized, then um the program will panic out because you can't assign a value to a nout map. I will show that here real quick. So, we can comment this code out.", "start": 621.68, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
20
+ {"text": "Go down here. We can say um with header and then we'll say please subscribe. And this hopefully will crash, right? That's what we expected. Um, assignment to entry in nil map. So, let's leave that code in. So, go back here. We can do this.", "start": 652.079, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
21
+ {"text": "So, now it's going to make that map if it doesn't exist. And there we have it.", "start": 678.959, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
22
+ {"text": "And this will also let us do multiple headers. So, if we wanted to add two headers, we can just say with header again, right? So, we can say um let's go back here with header and then say thank you, right? That's another header. Close that out. I'll just do that so it's a bit easier. Go run. And you can see we have headers. We have please subscribe and thank you. So, that's that. What else do we have to do? Um probably some check options, right? So, we have all this.", "start": 682.959, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
23
+ {"text": "Uh, we don't have with URL. We don't have a way to set the URL. That's crazy.", "start": 718.56, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
24
+ {"text": "Um, let's set that real quick. Uh, let's do funk with URL. And then we can say URL string HP optf funk. And we could do this, right? But I think the URL is going to be a requirement. So maybe I don't want to put that as my functional option pattern, right? We could also say new HP brute implementation and then put the URL here URL string right and then default options.", "start": 722.64, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
25
+ {"text": "Uh we can pass in the URL and we can take in URL here or we can do default options and set it. That's easier. So we can do O.", "start": 757.44, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
26
+ {"text": "URL is equal to URL. That's another way we can do it.", "start": 770.399, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
27
+ {"text": "And then here in our thing we have to specify. So we can do http ipsack rocks. And now we pass in the URL and then all the kind of optional things we need. Right? That's generally how I like coding my things. If I'm just giving you um like the functional option pattern, these are things that are probably going to be um optional or I said function optional pattern. the function options pattern. Um, but the things that are definitely hard requirements I just put up front, right?", "start": 775.68, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
28
+ {"text": "So when we look at the definition, you see, oh, we need the URL and all these are options we can do. We can change the request to a post if we want to. In the like documentation, you may see like the default. So it defaults to a get request, things like that. But um, yeah.", "start": 810.079, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
29
+ {"text": "So that's that. if we wanted to check things. So let's say we want to create a check function because we don't want invalid HTTP methods, right? So let's create a check there. And you can just put the check in after here after we do all the assignments. Um so we can do a funk and let's see. I'm going to actually say um let's do C. That's going to be a pointer to HTP ops. And I'm going to create a function called validate. And that will take a nothing and return an error. I think that's right. And let's see. Uh how do we want to do this? I'm going to check the um verbs two different ways. The first way is going to be the more basic way and then I'll show something a little bit more complex. Right? So let's create a funk and we'll say check HTTP method and we're going to take in the method as a string and then return", "start": 826.16, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
30
+ {"text": "an error and let's see we can say the valid methods are going to be a slice of string and we can say what um get post uh put and we'll do three. I can't think of anything else off the top of my head. We can just say for um method range methods and then we can do if strings equal fold. So we're saying if the method is equal to this then we're just going to return nil because there's no error there. And if we get through our loop um that's going to be an error, right?", "start": 885.36, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
31
+ {"text": "Because it did not match anything. So we can do um invalid method percent s like this and we just put method there. So that should be fine. And then invalidate we can say if check HP method um C do method let's see if error like this then error does not equal nil awesome return error and then return nil here and then in this code now we can say Um error is equal to C dot uh o.validate if error does not equal nil return error. Uh we have two things. So return nil error. We have to go up here. This has to be able to return error.", "start": 930.959, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
32
+ {"text": "And then here return the object and nothing. And then when we call it we also have to have error there because it's capable. And if error does not equal nil um fmt print f we'll just do print line on error. I think that'll work.", "start": 1003.519, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
33
+ {"text": "Let's see. Does this work? Go run. That printed out. So, let's change this post to something that is not valid. So, we'll just change it to and then go run.", "start": 1031.199, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
34
+ {"text": "And we get invalid method. So, that's the library telling us that doesn't work. Right. So, what was I talking about a better way to do this? Well, I don't like having um this function be on its own. I'd rather just do this all inside of validate. And the reason why I did this on the own because it gets somewhat complex doing something like this, right? But we can just really do a map lookup which will make it a bit easier. And what I meant about this like um we could store like the value. So um found we could do ver found is a boolean and then this could be found equals true.", "start": 1042.959, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
35
+ {"text": "And then down in the function say if found, right? That's not really that elegant and it it's just ugly. But let's use a um map lookup here. So I'm going to do a var valid methods and that's going to be a map string. Uh did I do that right? No. Um what is it? I do map string and what is it? I don't do that.", "start": 1084.559, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
36
+ {"text": "I think it's just struck like this.", "start": 1115.84, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
37
+ {"text": "Uh, no, I'm getting ahead of myself. I think that's it. Yeah. And then C-pilot can finish me. There we go. Uh, get post put. That's fine. So, we have a a map here.", "start": 1120.28, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
38
+ {"text": "I really hope that's right. Um, and now with this we're just going to say check if it's in it. So this would be the value that we extract. But um, we don't really care about that. We just care if it extracted, right? So we do that. And then we can say um, let's just delete this rest of line valid methods. And I'm going to do a strings to upper and we'll pass in ops method like that. And then we'll say if it's not okay then we will return fmt errorf invalid method. So I think that's right. So I think this is just the more elegant way. I think it's also a bit faster to do a map lookup than a loop but that should be fine. Um, ops undefined. Uh, this should be C ops I think. C method like that. There we go. Invalid method.", "start": 1136.64, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
39
+ {"text": "That's good. So, that is going to be how we can validate options. I'm not going to spend a lot of time creating that, but if I was creating a library, I'd put a lot more work into the validation. So, with all of this, I think we're ready to start migrating this code over into our LDAP injector. So, let's go back to our terminal, and I'm just going to copy main.go, and I'll put it in LDAP injector. I'm going to call it um hpops.go. Right. And let's go into this, and I'm going to close this window.", "start": 1209.36, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
40
+ {"text": "And then we can just open up zed again and then start working on this. So we want to open up um what is it? HTTP ops and then probably main and net hp. These are the three files we want. So first I'm going to get rid of this funk main, right? Because we definitely don't want that. And then let's see this new brute implementation. I'm probably going to just copy that over top. So let's take this go over to net http I can put that there. We will delete that definition. And then I'm also going to delete this new brute. Go back into our options. And then we're going to take it from here. That looks good.", "start": 1244.24, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
41
+ {"text": "Paste that. Save it. And I think most of this is pretty much done. Uh, save this code. Save this code. And here is where we're going to have our main change. So, we can say HTTP client error is equal to new HTTP brute implementation.", "start": 1301.12, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
42
+ {"text": "The URL we're going to do http internet ghost http 808 login and then we have to start doing the options. So I'll do a comma here. We can say with method post like that. And then let's see we need a with username. This can be get t temp principle.", "start": 1328.72, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
43
+ {"text": "Awesome.", "start": 1362.44, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
44
+ {"text": "Uh then with or expect status code.", "start": 1364.679, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
45
+ {"text": "Expected status code 303. What's the next thing? Oh, we need the headers. So, let's just yank these two. Put with header like this. That's a comma. And then do the same thing here.", "start": 1369.84, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
46
+ {"text": "And this can be deleted. And I think we're pretty much done. So if error does not equal nil, we can panic on this error. And you should only use panics when you're within main. Um because you never want your thread panicking. So only do it when you're in main. It's normally bad habit. Golang doesn't like you using panics, but hopefully this is just magically gonna work. It's taking its time and looks like it does. So, that is the function options pattern. There is one thing that I realized when I was doing this that I wanted to show that I didn't show. So, let's show that real quick. Um, to do that, I want to go back into my example. And hopefully I didn't delete anything here. I don't think I did. No, I didn't.", "start": 1398.0, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
47
+ {"text": "Um, we could have a thing like follow redirects. So, we can create something follow redirects and this can be boolean. And because we're not going to pass an option here, uh, we could simplify it. So, I'm going to show both ways. So, the easiest way, um, we'll say, uh, with redirects, I guess, um, I guess that's fine. like this. And this is how you'd kind of expect it to be used, right? And here now we can go with um with redirects true and go run. Uh we have an invalid method. Let's put this to be a valid one. Go run. We can see redirects is set to true. If I delete this line, we rerun it.", "start": 1451.799, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
48
+ {"text": "It did not save rerun. It's false. But since we're not passing in any argument here, we could simplify it a little bit and just make this the um HP op funk. I think let's see how am I doing this. Um we'll do ops HTTP ops. And I don't think we return anything.", "start": 1510.799, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
49
+ {"text": "And we can just say opsfollow redirects is equal to true.", "start": 1539.12, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
50
+ {"text": "Yep, this is it. And then for this, you could just say with redirects and not pass in like you don't do the parenthesis there because we're not passing in any extra options. And just by specifying that um you can see it gets set to true. So you could do it that way. Um, a lot of people generally frown upon this even though I think it's simpler to read, but it's just not obeying the conventions of all your other things. And Go really likes uniformity. So, like I would recommend doing it um this way, right? Uh there. There we go. That's undoed enough. So, that's how I would recommend doing it.", "start": 1543.84, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}
51
+ {"text": "So, I think that's pretty much going to be the video. So, hope you guys enjoyed it. Take care and I will see you all next time.", "start": 1590.679, "duration": 0.0, "meta": {"video_id": "p4VqejsO6oU", "title": "Golang for Hackers - LDAP Injector - Episode 04 - Functional Options Pattern", "url": "https://www.youtube.com/watch?v=p4VqejsO6oU"}}