So before we move on to server side form validation, I do want to take a little pause here and just
implement some refactoring and refactoring just means moving things around inside your project.
So if you look at our project structure right now, we have a command folder that has a web folder that
has the three files that establish our main routine, set up our middleware and our routine, and that's
fine.
That's a conventional way to build a Web application and go.
Then we have this package, this package folder, and inside of that we have config handlers, models
and render.
And that's fine because those are packages.
But conventionally and there is no hard and fast rule for this.
But conventionally, when you set up a project, anything in your package pkg folder is it means something
to people that are looking at your code.
It means these are resources that are completely divorced from the logic of your application and that
I can import into my own application.
And that's not the case here.
So, for example, this config that's only useful in our application, it depends upon a particular
session manager.
It has a structure that's of use to nobody except ourselves.
In the same way, obviously, our handlers are set up specifically for our application and so are our
models and so is our rendering engine.
So what I'm going to do is refactor.
I'm going to create a new directory here right at the root level of my application, and I'm going to
call it internal.
And that is where I'm going to move these packages.
So I'm going to it's going to be I'm going to take advantage of refactoring built into my application.
I'm going to select these three packages and I'm going to move them to internal those four packages,
I guess, and move them to internal.
And a little dialog pops up in my idee that says, are you sure you want to move these specified directories
from there to here?
And I'm going to check this box.
If it's not checked, check her references and that will do some of the heavy lifting for me.
So I'll refactor it.
So when I do that, things are going to break almost certainly if I try to run this application right
now, go run command Web Maime or Stargirl, chances are there's going to be an error.
Maybe not.
We'll find out here.
Look, it just started.
That worked beautifully.
All right?
So I'll stop the application and let's look at some of the things that have changed.
So back to my main package.
Anything changed there?
Yes.
Notice how it changed GitHub, dotcom, teszler bookings.
This used to say pkg.
And if yours doesn't, you need to change it to pkg from pkg to internal.
So change those for us in the Roots folder under the imports.
Same thing.
And went to internal.
And this makes more sense and it makes more sense because these packages are all internal to my application.
Now if I write something and I will later on in the course, probably if I write something that other
people can use, I'll stick that in the package folder.
So that wasn't too hard.
If your idea did not add automatically refactor things for you, just run it.
It'll tell you where the errors are and go change your imports.
And that's pretty much all you have to do.
And that's one of the great advantages of using an integrated development environment like Goaland.
And there's similar functionality in visual studio code or jet brains, intelligence of the public edition
or the community edition.
Most I.D. support refactoring out of the box.
So I'm going to commit these changes and push them up to get so refactored
to use internal.
Packages and push.
And we are good, so I shall commit push and it's all set.
All right, now in the next lecture, we'll move on to doing some server side form validation, which
is utterly critical, as you will see shortly.