WEBVTT 00:00.360 --> 00:05.660 We are now at the second video of this section starting with Hello World. 00:05.760 --> 00:12.240 In the previous video we learned how to install go on our machine and set up the workplace in this video. 00:12.240 --> 00:18.360 We are going to write a simple program to display Hello World and then have a look at integrated development 00:18.360 --> 00:21.300 environment that is idc. 00:21.510 --> 00:26.770 Then we will learn about types Variables Constants and operators. 00:26.790 --> 00:33.090 This wouldn't be a good course without a hello world example our hello world example can't be simpler. 00:33.120 --> 00:40.560 Open your favorite text editor and create a file called Main dot go within our go path source your name. 00:40.620 --> 00:46.310 Hello world let's open the terminal and type C D Go path. 00:46.320 --> 00:48.450 Now give the path of the file. 00:48.450 --> 00:52.040 Now let's create the main dot go file using nano. 00:52.100 --> 00:54.300 Write this content as I do it here 00:58.580 --> 01:05.150 save the file to run our program open the terminal window of your operating system once we are in our 01:05.150 --> 01:11.270 terminal navigate to the folder where we have created our main dot go file this should be on the or 01:11.270 --> 01:13.470 go path source your name. 01:13.490 --> 01:14.930 Hello world. 01:14.930 --> 01:20.930 Now execute this file using the go run main dot go and hit enter. 01:20.930 --> 01:24.620 You should see that we got the output which we intended that is. 01:24.620 --> 01:26.210 Hello world. 01:26.210 --> 01:32.900 That's all the go run command will compile and execute our application but it won't generate an executive 01:32.900 --> 01:33.920 all file. 01:33.920 --> 01:39.800 If you want to just build it and get an executive file you must build the app using the go build hyphen 01:39.910 --> 01:41.720 o command. 01:41.720 --> 01:44.090 So let's do it right now. 01:44.360 --> 01:51.650 Nothing happens but if you search in the current directory using Ellis command in line X and D I R in 01:51.650 --> 01:55.460 Windows you'll find an executive all file with the name. 01:55.460 --> 01:56.850 Hello world. 01:56.900 --> 02:02.030 So here's the executive file we have given this name to the executor Bill file. 02:02.030 --> 02:09.020 When we wrote hyphen Oh hello world command while building you can now execute this file as I do it 02:09.020 --> 02:13.010 here and our message appeared in windows. 02:13.010 --> 02:20.690 You just need to type the name of the dot XY file to get the same result then go run command will build 02:20.690 --> 02:27.040 and execute the app without intermediate files that go build hyphen command will create an executive 02:27.040 --> 02:31.750 all file that I can take anywhere and has no dependencies. 02:31.780 --> 02:37.100 Now let's talk about integrated development environment that is idc. 02:37.210 --> 02:43.720 An idea is basically a user interface to help developers code their programs by providing a set of tools 02:43.930 --> 02:51.430 to speed up common tasks during development processes like compiling building or managing dependencies. 02:51.430 --> 02:57.610 The ideas are powerful tools that take some time to master and the purpose of this book is not to explain 02:57.610 --> 02:59.350 them in go. 02:59.350 --> 03:05.440 You have many options but there are only two that are fully oriented to go development light idea and 03:05.530 --> 03:06.130 Intel. 03:06.140 --> 03:15.280 I j go gland light idea is not the most powerful though but Intel IJA has put lots of efforts to make 03:15.430 --> 03:16.300 go gland. 03:16.330 --> 03:23.620 A very nice ed with completion debugging refactoring testing visual coverage inspections etc.. 03:23.920 --> 03:30.760 Common ideas or text editors that have a go plug in or integration are listed on your screen but you 03:30.760 --> 03:36.010 can also find go plugins or vim and visual studio and visual code. 03:36.250 --> 03:43.360 The intel IJA idea and Atom ideas for the time of this writing has the support for debugging using a 03:43.360 --> 03:45.060 plugin called DL. 03:45.280 --> 03:50.970 The intel IJA idea is bundled with the official go plug in in atom. 03:51.010 --> 03:56.470 You'll have to download a plugin called go plus and the debugger that you can find searching the word 03:56.680 --> 03:58.050 delve. 03:58.090 --> 04:05.110 Next we move on to types as you must be aware types give the user the ability to store values and mnemonic 04:05.140 --> 04:12.390 names or programming languages have types related with numbers with characters with strings and so on. 04:12.550 --> 04:16.610 Go language as the common types found in most programming languages. 04:16.780 --> 04:22.270 You can read more about it at the official website that is go line dot org. 04:22.270 --> 04:28.660 Now let us step ahead and explore about variables and constants as discussed earlier we'll be using 04:28.870 --> 04:33.660 Intel IJA idea 2017 for this course. 04:33.670 --> 04:39.700 So variables are spaces in computer's memory to store values that can be modified during the execution 04:39.700 --> 04:46.690 of the program variables and constants have a type like the ones described in previous text although 04:46.780 --> 04:49.330 you don't need to explicitly write the type of them. 04:49.420 --> 04:51.370 Still you can do it. 04:51.370 --> 04:56.800 This property to avoid explicit type declaration is what is called inferred types. 04:56.800 --> 04:59.260 Let's take an example of this. 04:59.320 --> 05:05.670 Here we are declaring a variable with the keyword var called explicit of string type. 05:05.890 --> 05:10.030 At the same time we defined the value to Hello world. 05:10.180 --> 05:12.310 Let's add the line of code for this. 05:12.610 --> 05:15.450 But here we are doing exactly the same thing. 05:15.550 --> 05:22.600 We have avoided the VAR keyword and the string type declaration internally goes compiler will infer 05:22.600 --> 05:25.240 the type of the variable to a string type. 05:25.420 --> 05:30.660 This way you have to write much less code for each variable definition. 05:30.700 --> 05:36.960 Now these lines which I just added here use the reflect package to gather information about a variable. 05:36.970 --> 05:40.300 We're using it to print the type of both variables. 05:40.300 --> 05:42.810 Let's add the print f function. 05:43.040 --> 05:47.720 Go let's run the program and see the result as you run the program. 05:47.740 --> 05:52.260 You'll get three statements we used in the print function also. 05:53.510 --> 06:00.080 As we expected the compiler has inferred the type of the implicit variable to string to both have written 06:00.080 --> 06:04.170 the expected output to the console in this video. 06:04.200 --> 06:10.530 We have learned to write a program on hello world and had a brief description on different types variables 06:10.710 --> 06:13.890 and constants used in the Go language. 06:14.160 --> 06:17.670 In the next video we will explore about flow control.