- Go Code Structure and Analysis
- Global and Local Variables
- Constants
- Variables, Basic Data Types
- Scope
- Type Conversions
- Automatic memory management via garbage collection
- First-class functions
- Lexical (static) scope
- Standard library and APIs for basic structures such as collections (containers), networking, I/O, text processing, etc.
- Go and all of its libraries and tools are open-source.
- It is a compiled language
- Struct
- Go does not support custom types through classes but structs.
- Encapsulation
- It means hiding sensitive data from users.
Note: if function/struct is public as it begins with a capital letter, else it begins with a lower case.
- Inheritance
- subclass/child class are the terms used for the class which acquire properties in golang with struct.
- Interfaces
- The interface is a custom type that is used to specify a set of one or more method signatures.By treating objects of different types in a consistent way, as long as they stick to one interface, Golang implements polymorphism.
Golang is not a functional language but has a lot of features that enable to turning our code more elegant, concise, maintainable, easier to understand and test.
- Functions are first-class citizens.
- Supports anonymous functions or closures.
- os.Args is a slice of strings.
- Exercise 1.1 Code Example and Output text file
- Exercise 1.2 Code Example and Output text file
- Exercise 1.3 Code Example and Output text file & Output Picture
- Excercise 1.4 Code Example and Output text file
- Excercise 1.5 Code Example and Output text file & Output Picture
- Excercise 1.6 Code Example and Output text file & Output Picture
- Excercise 1.7 & Excercise 1.8 & Excercise 1.9 Code Example
- Ecercise 1.10 Code Example and Output text file
- Ecercise 1.11 Code Example and Output text file
- Ecercise 1.12 Code Example & Output Picture
- Go programmers use "camel case" when forming names by combining words; that is, interior capital letters are preferred over interior underscores.
- Four major kinds of declarations: var, const, type, and func.
- A pointer value is the address of a variable.
- Pointers are key to the flag package, which uses a program's command-line arguments to set the values of cer tain variables distributed throughout the program.
- The expression new(T) creates an unnamed variable of typ e T.
- Tuple assignment
type Celsius float64
type Fahrenheit float64
- Two types, Celsius and Fahrenheit, for the two units of temperature. Even though both have the same underlying typ e, float64, they are not the same type, so they cannot be compared or combined in arithmetic expressions.
- If a name is declared in both an outer block and an inner block, the inner declaration will be found first.
- Exercise 2.1 Code Example and Output text file
- Exercise 2.2 Code Example and Output text file
- Exercise 2.3 Code Example and Output text file & Output Picture
- Exercise 2.4 Code Example and Output text file & Output Picture
- Exercise 2.5 Code Example and Output text file & Output Picture
& bitwise AND
| bitwise OR
^ bitwise XOR
&^ bit cle ar (AND NOT)
<< lef t shif t
>> right shif t
- Exercise 3.1 Code Example and Output text file & Output Picture
- Exercise 3.2 Output Picture
- Exercise 3.3 Output Picture
- Exercise 3.4 Code Example and Output text file & [Output Picture
- Exercise 3.5 Output Picture
- Exercise 3.6 Output Picture
- Exercise 3.10 Code Example and Output text file
- Exercise 3.11 Code Example and Output text file & Output Picture
- Exercise 3.12 Code Example and Output text file