25 Basic Keywords Of The Go Programming Language (Learn 'Go' - Part 2)

in #programming7 years ago (edited)

The 'Go' programming language is considered simple to learn as compared to other programming languages like C++. C++ has more than 70 basic keywords, whereas 'Go' has 25 keywords. It has been designed to be easy and simple to implement while being efficient. It allows the developers to develop at a good speed but the number of keywords is not the only factor that determines the complexity of the language.

 

Here is the list of 25 reserved 'Go' keywords that you will be using all the time. It is good to get familiar with all of them even before you start developing any software using 'Go.' Remember, these are the reserved keywords and you cannot use them as identifiers.

 

 

  1. break - The 'break' keyword lets you terminate a loop and continue execution of the rest of the code.

  2. case - This is a form of a 'switch' construct. We specify a variable after the switch.

  3. chan - The 'chan' keyword is used to define a channel. In 'Go', you are allowed to run parallel pieces of code simultaneously.

  4. const - The 'const' keyword is used to introduce a name for a scalar value like 2 or 3.14, etc.

  5. continue - The 'continue' keyword allows you to go back to the beginning of the 'for' loop.

  6. default - The 'default' statement is optional but you need to use either case or default within the switch statement. The switch jumps to the default value if the case does not match the controlling expression.

  7. defer - The 'defer' keyword is used to defer the execution of a function until the surrounding function executes.

  8. else - The 'else' keyword is used with the 'if' keyword to execute an alternate statement if a certain condition is false.

  9. fallthrough - This keyword is used in a case within a switch statement. When we use this keyword, the next case is entered.

  10. for - The 'for' keyword is used to begin a for loop.

  11. func - The 'func' keyword is used to declare a function.

  12. go - The 'go' keyword triggers a goroutine which is managed by the golang-runtime.

  13. goto - The 'goto' keyword offers a jump to a labeled statement without any condition.

  14. if - The 'if' statement is used to check a certain condition within a loop.

  15. import - The 'import' keyword is used to import packages.

  16. interface - The 'interface' keyword is used to specify a method set. A method set is a list of methods for a type.

  17. map - The 'map' keyword defines a map type. A map os an unordered collection of the key-value pairs.

  18. package - The code is grouped as a unit in a package. The 'package' keyword is used to define one.

  19. range - The 'range' keyword lets you iterate items over the list items like a map or an array.

  20. return - Go allows you to use the return values as variables and you can use the 'return' keyword for that purpose.

  21. select - The 'select' keyword lets a goroutine to wait during the simultaneous communication operations.

  22. struct - Struct is a collection of fields. We can use the 'struct' keyword followed by the field declarations.

  23. switch - The 'switch' statement is used to start a loop and use the if-else logic within the block.

  24. type - We can use the 'type' keyword to introduce a new struct type.

  25. var - The 'var' keyword is used to create the variables in the 'Go' language.

 

If you are familiar with programming, you can make sense out of it instantly but if Go is your first programming language, you might not be able to make too much sense.

Don't worry! I have created this list only to make you familiar with the language. I will be covering all of them and other syntax elements in great detail in the upcoming posts. The learning has not even begun yet.


 
 
 
 

Thank You!


 
 
 

In Part 1, you got an Introduction To 'Go' Programming Language

 
 


 

In Part 3, you will learn 'How To Set The Go Programming Environment On Your System?'

 

In Part 4, you will 'Create Your First Program In Go language.'

Coin Marketplace

STEEM 0.21
TRX 0.25
JST 0.038
BTC 95814.43
ETH 3337.94
USDT 1.00
SBD 3.10