Understanding The Basic In Go¶
Learn the basic data types in Go
For a new programmer, data types sounds geeky enough, but really there isn't much to it, lets see below how it works out.
If I ask you, what's your name ? Yours answer would be something like this:
This is nothing but data type of , in plain english string is nothing but a collection of characters.
Now, if I ask you, how old are you ? You would say something like:
Since age is a number or a digit, it belongs to the data type of , int stands for integer which means whole numbers without decimals.
Let's get more curious and ask James Bond, you have a nice watch, how much did it cost ? He would say:
Now you see nice it has a decimal value, it is called as a data type of , float is just another fancy way of saying, its a digit with decimal values.
James Bond is getting irritated with our question, so lets ask a final question and wrap it up, lets ask, is it true that you are licensed to kill ? He would say
True is neither a digit or a string, its a condition, so it belongs to the data type of , boolean values can be only True or False.
In reality the above data types are of very basic types, Go has much more to it, also Go has different varieties of int, float, etc. But for now lets take it easy, we will see different data types as we progress with our code.
So now you know what are the basic data types in Go, in the next section we will start using them by declaring something called as and .