Press "Enter" to skip to content

More web dev basics – Go Lang Practical Programming Tutorial p.9


what’s going on everybody welcome to

what’s going on everybody welcome to part 9 of our go language tutorial

part 9 of our go language tutorial

part 9 of our go language tutorial series in this video what we’re going to

series in this video what we’re going to

series in this video what we’re going to be covering is more on the web server

be covering is more on the web server

be covering is more on the web server and kind of serving information back to

and kind of serving information back to

and kind of serving information back to the browser just some basic stuff that

the browser just some basic stuff that

the browser just some basic stuff that we should probably cover before we get

we should probably cover before we get

we should probably cover before we get into the nitty gritties so with that I’m

into the nitty gritties so with that I’m

into the nitty gritties so with that I’m starting with a blank screen here I

starting with a blank screen here I

starting with a blank screen here I guess it can serve as there’s kind of a

guess it can serve as there’s kind of a

guess it can serve as there’s kind of a reminder of the the web development

reminder of the the web development

reminder of the the web development basics but anyways packaged me we’re

basics but anyways packaged me we’re

basics but anyways packaged me we’re also gonna import a couple of things one

also gonna import a couple of things one

also gonna import a couple of things one is the just the format and then also net

is the just the format and then also net

is the just the format and then also net slash HTTP then we’re gonna have funk

slash HTTP then we’re gonna have funk

slash HTTP then we’re gonna have funk index underscore handler and in the

index underscore handler and in the

index underscore handler and in the parameters here it’s W and then that’s a

parameters here it’s W and then that’s a

parameters here it’s W and then that’s a HTTP response writer and then we had our

HTTP response writer and then we had our

HTTP response writer and then we had our for the request which is a point through

for the request which is a point through

for the request which is a point through to http dot request and now we can begin

to http dot request and now we can begin

to http dot request and now we can begin the function and let’s just do format

the function and let’s just do format

the function and let’s just do format dot F printf using the writer and then

dot F printf using the writer and then

dot F printf using the writer and then hey there for now and then finally we

hey there for now and then finally we

hey there for now and then finally we can do our funk mein empty parms and

can do our funk mein empty parms and

can do our funk mein empty parms and HTTP dot handle funk handle let’s try

HTTP dot handle funk handle let’s try

HTTP dot handle funk handle let’s try our best not to type out swear words

index Handler and then finally HTTP dot

index Handler and then finally HTTP dot listen and serve you can also if you had

listen and serve you can also if you had

listen and serve you can also if you had like HTTP for example you could listen

like HTTP for example you could listen

like HTTP for example you could listen to serve TLS not really gonna cover that

to serve TLS not really gonna cover that

to serve TLS not really gonna cover that now but you that just letting you know

now but you that just letting you know

now but you that just letting you know that exists forty eight thousand and

that exists forty eight thousand and

that exists forty eight thousand and then obviously you would serve on a

then obviously you would serve on a

then obviously you would serve on a different port but anyway back to what

different port but anyway back to what

different port but anyway back to what we were doing past nil go ahead and save

we were doing past nil go ahead and save

we were doing past nil go ahead and save that and let’s make sure that runs as we

that and let’s make sure that runs as we

that and let’s make sure that runs as we would hope so go run go to go touch go

would hope so go run go to go touch go

would hope so go run go to go touch go what did this comma that’s gonna keep

what did this comma that’s gonna keep

what did this comma that’s gonna keep getting me some Python you got you know

getting me some Python you got you know

getting me some Python you got you know you’d have to put in that comma probably

you’d have to put in that comma probably

you’d have to put in that comma probably to go to Python forget some commas yeah

to go to Python forget some commas yeah

to go to Python forget some commas yeah yeah

yeah

yeah since exterior unexpected funk expect

hmmm it’s not jumping out at me with

hmmm it’s not jumping out at me with this issue would be in ducks handler

this issue would be in ducks handler

this issue would be in ducks handler past W response writer

past W response writer

past W response writer okay if that should be fine

okay if that should be fine

okay if that should be fine mean you handle the funk the index

mean you handle the funk the index

mean you handle the funk the index handler hgp listen and serve 48,000 no

handler hgp listen and serve 48,000 no

handler hgp listen and serve 48,000 no what do we use a single quote yes we use

what do we use a single quote yes we use

what do we use a single quote yes we use single quotes that’s what’s getting us

single quotes that’s what’s getting us

single quotes that’s what’s getting us if I would have read the error info I

if I would have read the error info I

if I would have read the error info I would have seen that immediately all

would have seen that immediately all

would have seen that immediately all right let’s try it again

right let’s try it again

right let’s try it again there we go that’s gonna work allow and

there we go that’s gonna work allow and

there we go that’s gonna work allow and then I’ll head to it all right we gotta

then I’ll head to it all right we gotta

then I’ll head to it all right we gotta hey there so obviously we generally like

hey there so obviously we generally like

hey there so obviously we generally like that’s just plain text like review the

that’s just plain text like review the

that’s just plain text like review the source of justice is a they’re usually

source of justice is a they’re usually

source of justice is a they’re usually in HTML we have things called tags so

in HTML we have things called tags so

in HTML we have things called tags so what can we do to pass tags well we

what can we do to pass tags well we

what can we do to pass tags well we actually we can pass tags

actually we can pass tags

actually we can pass tags oops just by writing them in if we

oops just by writing them in if we

oops just by writing them in if we wanted so let’s just do header one for

wanted so let’s just do header one for

wanted so let’s just do header one for example and then I’m just gonna restart

example and then I’m just gonna restart

example and then I’m just gonna restart the server real quick maybe hit allow

the server real quick maybe hit allow

the server real quick maybe hit allow there we go right and now it’s hey there

there we go right and now it’s hey there

there we go right and now it’s hey there and then if we refresh the source we see

and then if we refresh the source we see

and then if we refresh the source we see us that the tags actually came through

us that the tags actually came through

us that the tags actually came through and all that so then we could add like a

and all that so then we could add like a

and all that so then we could add like a few more things like let’s just say

few more things like let’s just say

few more things like let’s just say maybe two more lines make this maybe a

maybe two more lines make this maybe a

maybe two more lines make this maybe a paragraph tag and then we’ll make this

paragraph tag and then we’ll make this

paragraph tag and then we’ll make this one a paragraph tag and then we can say

one a paragraph tag and then we can say

one a paragraph tag and then we can say goes fast and simple like so and then we

goes fast and simple like so and then we

goes fast and simple like so and then we can refresh our server I’m just breaking

can refresh our server I’m just breaking

can refresh our server I’m just breaking and restarting it so ctrl C and then

and restarting it so ctrl C and then

and restarting it so ctrl C and then just up arrow to aria rerun it basically

just up arrow to aria rerun it basically

just up arrow to aria rerun it basically and then as you can see we got that on

and then as you can see we got that on

and then as you can see we got that on separate lines and all that and it works

separate lines and all that and it works

separate lines and all that and it works as you would have expected the other

as you would have expected the other

as you would have expected the other thing I want to show real briefly is

thing I want to show real briefly is

thing I want to show real briefly is let’s just make another line and we can

let’s just make another line and we can

let’s just make another line and we can do something like this like we could say

do something like this like we could say

do something like this like we could say use percent s even add percent s

use percent s even add percent s

use percent s even add percent s , and then we can put in what we want to

, and then we can put in what we want to

, and then we can put in what we want to have there so we could say can and and

have there so we could say can and and

have there so we could say can and and then we can also say what did I do here

then we can also say what did I do here

then we can also say what did I do here okay sewed up them strong and then pass

okay sewed up them strong and then pass

okay sewed up them strong and then pass variables so you can even add variables

variables so you can even add variables

variables so you can even add variables like this using the the person s so it’s

like this using the the person s so it’s

like this using the the person s so it’s good break let’s rerun it wow it wish I

good break let’s rerun it wow it wish I

good break let’s rerun it wow it wish I have to hit a lot every time refresh

have to hit a lot every time refresh

have to hit a lot every time refresh pull it over and there you go hey there

pull it over and there you go hey there

pull it over and there you go hey there goes fast and simple you can even add

goes fast and simple you can even add

goes fast and simple you can even add variables the next thing I want to show

variables the next thing I want to show

variables the next thing I want to show though is if we were to view the source

though is if we were to view the source

though is if we were to view the source here everything is on just like one line

here everything is on just like one line

here everything is on just like one line which I mean it’s probably not the end

which I mean it’s probably not the end

which I mean it’s probably not the end of the world but in general we would

of the world but in general we would

of the world but in general we would like this to be organized like you would

like this to be organized like you would

like this to be organized like you would have expect especially when things start

have expect especially when things start

have expect especially when things start getting like if you were gonna actually

getting like if you were gonna actually

getting like if you were gonna actually code a website doing this like you

code a website doing this like you

code a website doing this like you probably wouldn’t you’d probably move to

probably wouldn’t you’d probably move to

probably wouldn’t you’d probably move to using templates which we’ll show at a

using templates which we’ll show at a

using templates which we’ll show at a later time but if you were doing it this

later time but if you were doing it this

later time but if you were doing it this way it would be very hard for you to

way it would be very hard for you to

way it would be very hard for you to debug your own website especially if

debug your own website especially if

debug your own website especially if you’ve got issues like you forgot to

you’ve got issues like you forgot to

you’ve got issues like you forgot to close a tag somewhere it’s really hard

close a tag somewhere it’s really hard

close a tag somewhere it’s really hard to find it and it’s gonna be equally as

to find it and it’s gonna be equally as

to find it and it’s gonna be equally as hard to find it if if it looks like that

hard to find it if if it looks like that

hard to find it if if it looks like that so so the other thing we could do is you

so so the other thing we could do is you

so so the other thing we could do is you can actually do like a multi-line print

can actually do like a multi-line print

can actually do like a multi-line print so this is true with all the prints you

so this is true with all the prints you

so this is true with all the prints you don’t have to use F print you could this

don’t have to use F print you could this

don’t have to use F print you could this could just be like at your typical print

could just be like at your typical print

could just be like at your typical print line for example but what I’m gonna go

line for example but what I’m gonna go

line for example but what I’m gonna go ahead and do is like let’s say we wanted

ahead and do is like let’s say we wanted

ahead and do is like let’s say we wanted this exact same code so format dot F

this exact same code so format dot F

this exact same code so format dot F print F and let’s just blow just do

print F and let’s just blow just do

print F and let’s just blow just do these first three I think and then you

these first three I think and then you

these first three I think and then you can use the little Tilly and then you

can use the little Tilly and then you

can use the little Tilly and then you can use that to make a multi-line print

can use that to make a multi-line print

can use that to make a multi-line print so for example we could throw in all you

so for example we could throw in all you

so for example we could throw in all you don’t need the quotes we could throw in

don’t need the quotes we could throw in

don’t need the quotes we could throw in that this and we’ll just throw in this

that this and we’ll just throw in this

that this and we’ll just throw in this one just for just to show it

one just for just to show it

one just for just to show it okay we can save that actually I’m gonna

okay we can save that actually I’m gonna

okay we can save that actually I’m gonna get rid of these two so we’ll save that

get rid of these two so we’ll save that

get rid of these two so we’ll save that and then I’ll restart the server oops we

and then I’ll restart the server oops we

and then I’ll restart the server oops we have a mistake not enough arguments oh

have a mistake not enough arguments oh

have a mistake not enough arguments oh we forgot the W the writer try again

we forgot the W the writer try again

we forgot the W the writer try again there it goes

refresh and basically kind of the same

refresh and basically kind of the same thing everything’s on a separate line

thing everything’s on a separate line

thing everything’s on a separate line and if we were to go view the source

and if we were to go view the source

and if we were to go view the source you’d see well it’s almost good enough

you’d see well it’s almost good enough

you’d see well it’s almost good enough but not quite so the issue is the

but not quite so the issue is the

but not quite so the issue is the tabbing is at least yet like in the

tabbing is at least yet like in the

tabbing is at least yet like in the start it’s not going to be tabbed weird

start it’s not going to be tabbed weird

start it’s not going to be tabbed weird but then down here in theory these tabs

but then down here in theory these tabs

but then down here in theory these tabs are part of the multi-line so it’s

are part of the multi-line so it’s

are part of the multi-line so it’s thinking you want those tabs so you

thinking you want those tabs so you

thinking you want those tabs so you could get rid of them just by removing

could get rid of them just by removing

could get rid of them just by removing the tabs but again that’s probably not

the tabs but again that’s probably not

the tabs but again that’s probably not what you would want either and so again

what you would want either and so again

what you would want either and so again I’ll just kind of let you know that it

I’ll just kind of let you know that it

I’ll just kind of let you know that it does exist that there are going to be

does exist that there are going to be

does exist that there are going to be HTML templates and like I said we can

HTML templates and like I said we can

HTML templates and like I said we can look into those later on

look into those later on

look into those later on for solving this sort of a problem but

for solving this sort of a problem but

for solving this sort of a problem but again we can be a source for fresh and

again we can be a source for fresh and

again we can be a source for fresh and there we go we’ve fixed that problem but

there we go we’ve fixed that problem but

there we go we’ve fixed that problem but it is kinda neat you could in theory do

it is kinda neat you could in theory do

it is kinda neat you could in theory do quite a bit of programming and make even

quite a bit of programming and make even

quite a bit of programming and make even some slightly complicated websites just

some slightly complicated websites just

some slightly complicated websites just by passing variables just like we’ve

by passing variables just like we’ve

by passing variables just like we’ve done here and using all the information

done here and using all the information

done here and using all the information that we’ve learned up to this point we

that we’ve learned up to this point we

that we’ve learned up to this point we could actually make a decent website to

could actually make a decent website to

could actually make a decent website to be honest but in general I think you’ll

be honest but in general I think you’ll

be honest but in general I think you’ll find that using templates will be a

find that using templates will be a

find that using templates will be a little easier than doing it this way but

little easier than doing it this way but

little easier than doing it this way but anyways I think that’s all I want really

anyways I think that’s all I want really

anyways I think that’s all I want really show right now as far as like just kind

show right now as far as like just kind

show right now as far as like just kind of adding one layer on top of the stuff

of adding one layer on top of the stuff

of adding one layer on top of the stuff that we’ve seen so far in the next

that we’ve seen so far in the next

that we’ve seen so far in the next tutorial we’re actually gonna start

tutorial we’re actually gonna start

tutorial we’re actually gonna start building our projects so the project

building our projects so the project

building our projects so the project that I wanted to do I just basically

that I wanted to do I just basically

that I wanted to do I just basically want to do anything but a blog so so the

want to do anything but a blog so so the

want to do anything but a blog so so the project I decided that we could do is to

project I decided that we could do is to

project I decided that we could do is to basically make like a news aggregator

basically make like a news aggregator

basically make like a news aggregator using like the sitemaps from a new

using like the sitemaps from a new

using like the sitemaps from a new source so so that’s what we’re gonna do

source so so that’s what we’re gonna do

source so so that’s what we’re gonna do and I think that’ll kind of allow us to

and I think that’ll kind of allow us to

and I think that’ll kind of allow us to bring in a bunch of concepts that we’re

bring in a bunch of concepts that we’re

bring in a bunch of concepts that we’re trying to learn and at the same time

trying to learn and at the same time

trying to learn and at the same time kind of actually use them on a real

kind of actually use them on a real

kind of actually use them on a real example rather than something that’s

example rather than something that’s

example rather than something that’s like a toy example because a lot of

like a toy example because a lot of

like a toy example because a lot of things really do change when you try to

things really do change when you try to

things really do change when you try to go from like a basic example to actually

go from like a basic example to actually

go from like a basic example to actually applying it so so anyways we’re actually

applying it so so anyways we’re actually

applying it so so anyways we’re actually gonna start building that code that’s

gonna start building that code that’s

gonna start building that code that’s going to start doing that for us we’re

going to start doing that for us we’re

going to start doing that for us we’re going to do that in the next tutorials

going to do that in the next tutorials

going to do that in the next tutorials so that’s what you guys have to look

so that’s what you guys have to look

so that’s what you guys have to look forward to if you’ve got questions

forward to if you’ve got questions

forward to if you’ve got questions comments concerns whatever feel free to

comments concerns whatever feel free to

comments concerns whatever feel free to leave them below otherwise I’ll see you

leave them below otherwise I’ll see you

leave them below otherwise I’ll see you in the next tutorial

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *