Go Keywords
Go Keywords
Go has keywords that are reserved words that cannot be used as variable names, function names, or any other identifiers. You will learn more about each of these keywords in later chapters. Go keywords are:
| Keyword | Description |
|---|---|
| break | Used to break out of a loop |
| case | Used in conditional statements with switch |
| chan | Used to declare a channel |
| const | Used to declare a constant variable |
| continue | Used to continue to the next iteration of a loop |
| default | Used in conditional statements with switch |
| defer | Defers the execution of a function until the end of the surrounding function |
| else | Used in conditional statements |
| fallthrough | Used in conditional statements with switch |
| for | Used to create a loop |
| func | Used to define a function |
| Go | Used to start the execution of a function call as an independent concurrent thread |
| Goto | Used to jump to the statement with the corresponding label within the same function. |
| if | Used to make a conditional statement |
| import | Used to import a package |
| Interface | Is an abstract type |
| maps | Maps keys to values |
| package | Used to define which package a .go file belongs to. |
| range | Used in for loops |
| return | Used to exit a function and return a value |
| select | Used in conditional statements It looks similar to a "switch" statement but with the cases all referring to communication operations. |
| struct | Used to declare a structure |
| switch | Used in conditional statements |
| type | Used to create a new data type |
| var | Used to declare variables. |