WEBVTT 00:00.420 --> 00:01.150 Hello. 00:01.260 --> 00:05.010 We are now at the last video of the section go tools. 00:05.130 --> 00:07.890 In the previous video we dived into libraries. 00:07.950 --> 00:13.950 In this video we will have a look at different tools and go like go lint go f. 00:13.980 --> 00:15.470 Empty tool. 00:15.540 --> 00:20.320 We will also see how to contribute to go open source projects in get help. 00:20.430 --> 00:25.900 Go comes with a series of useful tools to ease the development process every day. 00:25.920 --> 00:29.070 Also in the Go Lange page of GetUp. 00:29.130 --> 00:34.190 There are some tools that are supported by the go team but they are not part of the compiler. 00:34.230 --> 00:41.070 Most of the projects use tools such as Go f empty so that all the code base looks similar go dog helps 00:41.070 --> 00:47.280 us to find useful information NGO's documentation and the go import command to auto import the packages 00:47.280 --> 00:48.540 we are using. 00:48.540 --> 00:50.010 Let's see them. 00:50.100 --> 00:56.880 So let's start with the go lent to a lender analyse the source code to detect errors or improvements 00:57.220 --> 01:06.750 that go lent lender is available on GitHub dot com slash go Lang slashed lent for installation. 01:06.750 --> 01:13.470 It doesn't come bundled with the compiler it is very easy to use and has integrated some I.D. to be 01:13.470 --> 01:16.200 run when you save a source code file. 01:16.200 --> 01:21.570 Do you remember this implicit or explicit code that we run when talking about variables. 01:21.680 --> 01:25.280 Let's Lintott let us move on to the command line terminal. 01:25.500 --> 01:27.650 Let me clear the screen here. 01:27.650 --> 01:27.960 Type. 01:27.960 --> 01:28.720 Go lint. 01:28.740 --> 01:29.370 Main Dot. 01:29.370 --> 01:29.880 Go. 01:29.880 --> 01:30.810 Enter. 01:30.840 --> 01:32.120 So the main Dot. 01:32.130 --> 01:32.670 Go. 01:32.670 --> 01:39.990 9 colon 15 command should omit the type string from the Declaration of the explicit string variable. 01:39.990 --> 01:43.590 It will be inferred from the right hand side. 01:43.740 --> 01:49.560 It is telling us that go compiler will actually infer this type of a variable from the code and you 01:49.560 --> 01:51.870 don't need to declare its type. 01:51.960 --> 01:55.130 What about the train type on the interface section. 01:55.170 --> 01:59.120 Here's the train type in the interface section I was talking about. 01:59.370 --> 02:02.960 Let's get back to the terminal and lint this first. 02:02.970 --> 02:05.700 We need to navigate to Hello world. 02:05.700 --> 02:08.250 Then execute the go lint main Dot. 02:08.250 --> 02:09.350 Go command. 02:09.600 --> 02:15.540 Now the main dot goes 16 dot six colon type exported train type. 02:15.540 --> 02:19.050 Should have a comment or remain not exported. 02:19.050 --> 02:25.530 In this case it's pointing us that a public type such as train type must be commented so that the users 02:25.530 --> 02:29.480 can read the generated documentation to know its behavior. 02:29.490 --> 02:36.960 Now let's move on to the go f empty to the go F.M. t tool comes bundled with the compiler that already 02:36.960 --> 02:38.290 has access to it. 02:38.310 --> 02:44.340 Its purpose is to provide a set of indentation formatting spacing and a few other rules to achieve good 02:44.340 --> 02:46.080 looking go code. 02:46.080 --> 02:52.980 For example let's take the code of hello world and make it a bit weirder by inserting spaces everywhere. 02:52.980 --> 02:54.350 Let us navigate to the main Dot. 02:54.350 --> 02:55.560 Go file. 02:55.560 --> 02:59.280 Here we have the main function to print Hello World. 02:59.280 --> 03:03.170 Now let's go back to our terminal and type the command go f. 03:03.210 --> 03:09.050 Empty main dot go within the go path where our main dot go file is saved. 03:09.210 --> 03:11.070 Let's click enter. 03:11.070 --> 03:15.490 So you can see the output over here the go f empty command. 03:15.500 --> 03:16.860 Prints it correctly. 03:16.890 --> 03:22.650 Again what is more we can use the hyphen w flag to overwrite the original file. 03:22.650 --> 03:29.190 Let's add this and execute the command again and now we'll have our file properly corrected. 03:29.190 --> 03:35.160 Now we move on to learn how to contribute to go open source projects in get hub. 03:35.160 --> 03:40.650 One important thing to mention about go packaging systems is that it needs to have a proper folder structure 03:40.650 --> 03:42.360 within the go path. 03:42.360 --> 03:46.200 This introduces a small problem when working with get hub projects. 03:46.290 --> 03:51.930 We are used to forking a project cloning our folk and starting work before committing the pull request 03:52.050 --> 03:53.650 to the original project. 03:53.760 --> 03:55.050 Wrong. 03:55.050 --> 04:00.310 When you fork a project you create a new repository on GitHub within your user name. 04:00.330 --> 04:05.760 If you clone this repository and start working with it all new import references in the project will 04:05.760 --> 04:09.340 point to your repository instead of the original. 04:09.360 --> 04:14.850 Imagine the case in the original repository which I'm going to show you now with main package get hub 04:14.880 --> 04:19.020 dot com original library and there's some code. 04:19.020 --> 04:25.080 Then you make a fork and add a sub folder with a library called library forward slash my library that 04:25.080 --> 04:27.210 you want to use from the main package. 04:27.210 --> 04:29.920 The result is going to be something like this. 04:30.120 --> 04:36.120 Now if you commit this line the original repository that contains the code you have pushed will download 04:36.180 --> 04:42.870 this code anyways from your account again and it will use the references downloaded not the ones contained 04:42.990 --> 04:44.660 in the project. 04:44.670 --> 04:50.880 So the solution to this is simply to replace the get clone command with a go get pointing to the original 04:50.880 --> 04:51.870 library. 04:51.900 --> 04:54.680 So in this case we'll use this command. 04:54.690 --> 04:58.570 So here we use the go get command instead of cloning. 04:58.650 --> 05:04.290 Then you need to use the C D command followed by the path where you saved the files. 05:04.290 --> 05:07.310 Next is the g I.T. remote. 05:07.470 --> 05:14.070 To add my origin command with the link of the get hub page where the library could be found. 05:14.070 --> 05:19.620 With this modification you can work normally in the original code without fear as the references will 05:19.620 --> 05:21.710 stay correct once you are done. 05:21.780 --> 05:24.600 You just have to commit and push to your remote. 05:24.600 --> 05:27.180 Here's the command which you could use for this. 05:27.420 --> 05:31.330 Get push followed by the origin and the branch. 05:31.350 --> 05:36.990 This way you can now access to get hub web user interface and open the pull request without polluting 05:36.990 --> 05:41.100 the actual original code with references to your account. 05:41.220 --> 05:44.070 I can show you this through my get hub page. 05:44.160 --> 05:46.760 Let's move to the terminal type here. 05:46.770 --> 05:49.440 Go get and path of the source directory 05:59.600 --> 06:03.070 okay now C.D. the same path. 06:03.210 --> 06:04.980 Now we're within this path. 06:05.010 --> 06:07.770 Let's use the get remote ad command. 06:07.770 --> 06:15.090 As I showed you previously as you can see we got the message that remote my origin already exists since 06:15.090 --> 06:16.710 I already did it. 06:16.710 --> 06:21.600 Now use the get push command. 06:21.720 --> 06:24.780 Now if the user name and your password. 06:25.080 --> 06:26.070 It's done. 06:26.250 --> 06:27.650 Awesome. 06:27.690 --> 06:33.750 So now after this first section you must be familiar with the syntax of go and some of the command line 06:33.750 --> 06:36.450 tools that come bundled with the compiler. 06:36.450 --> 06:42.270 We have left a part concurrency capabilities for the next part of this video of course as they are large 06:42.300 --> 06:47.190 and pretty complex to grasp at the beginning so that you can learn the syntax of the language first 06:47.400 --> 06:53.400 become familiar and confident with it and then you can jump to understanding communicating sequential 06:53.400 --> 06:59.460 processes that is CSP concurrency patterns and distributed applications. 06:59.460 --> 07:05.400 The next steps are to start with the creation or design patterns in the next section. 07:05.460 --> 07:08.880 We will jump right in to use creation or design patterns.