Hello.
We are now at the last video of the section go tools.
In the previous video we dived into libraries.
In this video we will have a look at different tools and go like go lint go f.
Empty tool.
We will also see how to contribute to go open source projects in get help.
Go comes with a series of useful tools to ease the development process every day.
Also in the Go Lange page of GetUp.
There are some tools that are supported by the go team but they are not part of the compiler.
Most of the projects use tools such as Go f empty so that all the code base looks similar go dog helps
us to find useful information NGO's documentation and the go import command to auto import the packages
we are using.
Let's see them.
So let's start with the go lent to a lender analyse the source code to detect errors or improvements
that go lent lender is available on GitHub dot com slash go Lang slashed lent for installation.
It doesn't come bundled with the compiler it is very easy to use and has integrated some I.D. to be
run when you save a source code file.
Do you remember this implicit or explicit code that we run when talking about variables.
Let's Lintott let us move on to the command line terminal.
Let me clear the screen here.
Type.
Go lint.
Main Dot.
Go.
Enter.
So the main Dot.
Go.
9 colon 15 command should omit the type string from the Declaration of the explicit string variable.
It will be inferred from the right hand side.
It is telling us that go compiler will actually infer this type of a variable from the code and you
don't need to declare its type.
What about the train type on the interface section.
Here's the train type in the interface section I was talking about.
Let's get back to the terminal and lint this first.
We need to navigate to Hello world.
Then execute the go lint main Dot.
Go command.
Now the main dot goes 16 dot six colon type exported train type.
Should have a comment or remain not exported.
In this case it's pointing us that a public type such as train type must be commented so that the users
can read the generated documentation to know its behavior.
Now let's move on to the go f empty to the go F.M. t tool comes bundled with the compiler that already
has access to it.
Its purpose is to provide a set of indentation formatting spacing and a few other rules to achieve good
looking go code.
For example let's take the code of hello world and make it a bit weirder by inserting spaces everywhere.
Let us navigate to the main Dot.
Go file.
Here we have the main function to print Hello World.
Now let's go back to our terminal and type the command go f.
Empty main dot go within the go path where our main dot go file is saved.
Let's click enter.
So you can see the output over here the go f empty command.
Prints it correctly.
Again what is more we can use the hyphen w flag to overwrite the original file.
Let's add this and execute the command again and now we'll have our file properly corrected.
Now we move on to learn how to contribute to go open source projects in get hub.
One important thing to mention about go packaging systems is that it needs to have a proper folder structure
within the go path.
This introduces a small problem when working with get hub projects.
We are used to forking a project cloning our folk and starting work before committing the pull request
to the original project.
Wrong.
When you fork a project you create a new repository on GitHub within your user name.
If you clone this repository and start working with it all new import references in the project will
point to your repository instead of the original.
Imagine the case in the original repository which I'm going to show you now with main package get hub
dot com original library and there's some code.
Then you make a fork and add a sub folder with a library called library forward slash my library that
you want to use from the main package.
The result is going to be something like this.
Now if you commit this line the original repository that contains the code you have pushed will download
this code anyways from your account again and it will use the references downloaded not the ones contained
in the project.
So the solution to this is simply to replace the get clone command with a go get pointing to the original
library.
So in this case we'll use this command.
So here we use the go get command instead of cloning.
Then you need to use the C D command followed by the path where you saved the files.
Next is the g I.T. remote.
To add my origin command with the link of the get hub page where the library could be found.
With this modification you can work normally in the original code without fear as the references will
stay correct once you are done.
You just have to commit and push to your remote.
Here's the command which you could use for this.
Get push followed by the origin and the branch.
This way you can now access to get hub web user interface and open the pull request without polluting
the actual original code with references to your account.
I can show you this through my get hub page.
Let's move to the terminal type here.
Go get and path of the source directory
okay now C.D. the same path.
Now we're within this path.
Let's use the get remote ad command.
As I showed you previously as you can see we got the message that remote my origin already exists since
I already did it.
Now use the get push command.
Now if the user name and your password.
It's done.
Awesome.
So now after this first section you must be familiar with the syntax of go and some of the command line
tools that come bundled with the compiler.
We have left a part concurrency capabilities for the next part of this video of course as they are large
and pretty complex to grasp at the beginning so that you can learn the syntax of the language first
become familiar and confident with it and then you can jump to understanding communicating sequential
processes that is CSP concurrency patterns and distributed applications.
The next steps are to start with the creation or design patterns in the next section.
We will jump right in to use creation or design patterns.