We are now at the second video of this section starting with Hello World.
In the previous video we learned how to install go on our machine and set up the workplace in this video.
We are going to write a simple program to display Hello World and then have a look at integrated development
environment that is idc.
Then we will learn about types Variables Constants and operators.
This wouldn't be a good course without a hello world example our hello world example can't be simpler.
Open your favorite text editor and create a file called Main dot go within our go path source your name.
Hello world let's open the terminal and type C D Go path.
Now give the path of the file.
Now let's create the main dot go file using nano.
Write this content as I do it here
save the file to run our program open the terminal window of your operating system once we are in our
terminal navigate to the folder where we have created our main dot go file this should be on the or
go path source your name.
Hello world.
Now execute this file using the go run main dot go and hit enter.
You should see that we got the output which we intended that is.
Hello world.
That's all the go run command will compile and execute our application but it won't generate an executive
all file.
If you want to just build it and get an executive file you must build the app using the go build hyphen
o command.
So let's do it right now.
Nothing happens but if you search in the current directory using Ellis command in line X and D I R in
Windows you'll find an executive all file with the name.
Hello world.
So here's the executive file we have given this name to the executor Bill file.
When we wrote hyphen Oh hello world command while building you can now execute this file as I do it
here and our message appeared in windows.
You just need to type the name of the dot XY file to get the same result then go run command will build
and execute the app without intermediate files that go build hyphen command will create an executive
all file that I can take anywhere and has no dependencies.
Now let's talk about integrated development environment that is idc.
An idea is basically a user interface to help developers code their programs by providing a set of tools
to speed up common tasks during development processes like compiling building or managing dependencies.
The ideas are powerful tools that take some time to master and the purpose of this book is not to explain
them in go.
You have many options but there are only two that are fully oriented to go development light idea and
Intel.
I j go gland light idea is not the most powerful though but Intel IJA has put lots of efforts to make
go gland.
A very nice ed with completion debugging refactoring testing visual coverage inspections etc..
Common ideas or text editors that have a go plug in or integration are listed on your screen but you
can also find go plugins or vim and visual studio and visual code.
The intel IJA idea and Atom ideas for the time of this writing has the support for debugging using a
plugin called DL.
The intel IJA idea is bundled with the official go plug in in atom.
You'll have to download a plugin called go plus and the debugger that you can find searching the word
delve.
Next we move on to types as you must be aware types give the user the ability to store values and mnemonic
names or programming languages have types related with numbers with characters with strings and so on.
Go language as the common types found in most programming languages.
You can read more about it at the official website that is go line dot org.
Now let us step ahead and explore about variables and constants as discussed earlier we'll be using
Intel IJA idea 2017 for this course.
So variables are spaces in computer's memory to store values that can be modified during the execution
of the program variables and constants have a type like the ones described in previous text although
you don't need to explicitly write the type of them.
Still you can do it.
This property to avoid explicit type declaration is what is called inferred types.
Let's take an example of this.
Here we are declaring a variable with the keyword var called explicit of string type.
At the same time we defined the value to Hello world.
Let's add the line of code for this.
But here we are doing exactly the same thing.
We have avoided the VAR keyword and the string type declaration internally goes compiler will infer
the type of the variable to a string type.
This way you have to write much less code for each variable definition.
Now these lines which I just added here use the reflect package to gather information about a variable.
We're using it to print the type of both variables.
Let's add the print f function.
Go let's run the program and see the result as you run the program.
You'll get three statements we used in the print function also.
As we expected the compiler has inferred the type of the implicit variable to string to both have written
the expected output to the console in this video.
We have learned to write a program on hello world and had a brief description on different types variables
and constants used in the Go language.
In the next video we will explore about flow control.