/learning-golang-fundamentals

A repository for learning the basics of go

Primary LanguageGoMIT LicenseMIT

Learning GoLang Fundamentals

This repository is dedicated to learning and understanding the fundamental concepts of the Go programming language. It provides a comprehensive guide to understanding the core principles of Go.

Table of Contents

Package Variables
Data Types Functions
Operators Structs
Inheritance Pointers
Arrays Slices
Map If-Else
Switch Loops
Named Return Variatic Functions
Anonymous Functions Recursive Functions
Defer Panic
Recover Closure
Pointers in Functions Methods
Interfaces Interface Generics

Package

The Package section covers the basics of Go packages, which are used to organize and reuse code. It explains how to create and use packages, as well as best practices for structuring your code.

Variables

In the Variables section, you will learn about variable declaration, initialization, and assignment in Go. It covers different variable scopes, data types, and naming conventions. Additionally, it introduces the concept of constants in Go.

Data Types

The Data Types section focuses on the various data types available in Go, such as integers, floating-point numbers, strings, booleans, arrays, slices, maps, and structs. It provides examples and explanations for working with each data type.

Functions

The Functions section explores the concept of functions in Go. It covers function declaration, parameters, return values, and how to write reusable and modular code using functions. You will also learn about anonymous functions and function closures.

Operators

In the Operators section, you will learn about the different operators in Go, including arithmetic, comparison, logical, and assignment operators. It explains their usage and provides examples to demonstrate their behavior.

Structs

The Structs section delves into struct types in Go, which allow you to create custom composite data types. It covers struct declaration, initialization, accessing fields, and working with methods defined on structs.

Inheritance

The Inheritance section discusses the concept of inheritance in Go. Although Go does not support traditional inheritance, it provides an alternative approach through embedding and composition. This section explores how to achieve code reuse and polymorphism in Go using these techniques.

Pointers

The Pointers section explains the concept of pointers in Go, which allow you to manipulate memory directly. It covers pointer declaration, assignment, dereferencing, and the distinction between pass-by-value and pass-by-reference.

Arrays

The Arrays section covers the usage of arrays in Go, which are fixed-size collections of elements of the same type. It explains array declaration, initialization, accessing elements, and common array operations.

Slices

The Slices section explores slices in Go, which are flexible and dynamic views of arrays. It covers slice declaration, creation, appending and deleting elements, and manipulating slices using built-in functions.

Map

The Map section discusses the usage of maps in Go, which are key-value pairs. It covers map declaration, initialization, adding and deleting elements, iterating over maps, and common map operations.

If-Else

The if-Else section covers conditional statements in Go. It explains how to use if-else statements to make decisions based on certain conditions, as well as nested if-else statements and the usage of logical operators.

Switch

The switch section discusses the switch statement in Go, which provides a concise way to evaluate multiple conditions. It covers the syntax of switch statements, including the use of cases, fallthrough, and default cases.

Loops

The loops section explores the different types of loops

Named Return

The Named Return section discusses the usage of named return values in Go functions. It covers how to declare and use named return values to improve code readability and facilitate error handling.

Variatic Functions

The Variatic Functions section explains variadic functions in Go, which allow you to define functions that can accept a variable number of arguments. It covers the syntax and usage of variadic functions.

Anonymous Functions

The Anonymous Functions section explores anonymous functions in Go, which are functions without a name. It covers how to declare and use anonymous functions, as well as their benefits in certain scenarios.

Recursive Functions

The Recursive Functions section discusses recursive functions in Go, which are functions that call themselves. It explains how to write and use recursive functions to solve problems that can be divided into smaller subproblems.

Defer

The Defer section covers the defer statement in Go, which is used to schedule a function call to be executed later, usually when the surrounding function exits. It explains the usage and behavior of defer statements.

Panic

The Panic section explains the panic mechanism in Go, which is used to cause a program to terminate abruptly and print an error message. It covers how to use panic and how it interacts with deferred functions.

Recover

The Recover section discusses the recover function in Go, which is used to handle panics and resume normal execution. It explains how to use recover in combination with defer to catch and handle panics.

Closure

The Closure section explores closures in Go, which are functions that capture and access variables from their surrounding context. It covers the concept of lexical scoping and demonstrates how closures can be used.

Pointers in Functions

The Pointers in Functions section focuses on the usage of pointers as function parameters and return values in Go. It explains how pointers can be used to modify variables passed as arguments to functions and how to create and manipulate pointer types within function bodies.

This section covers topics such as passing pointers to functions, dereferencing pointers, returning pointers from functions, and the relationship between pointers and memory allocation. It provides examples and explanations to help you understand the concepts and effectively use pointers in your Go programs.

Init

The Init section covers the init function in Go, which is a special function that is executed automatically before the main function. It explains the purpose and usage of the init function in Go programs.

Feel free to explore each section in the order that suits your learning journey. Happy coding!

Methods

The Methods section explores the concept of methods in Go. It covers the declaration and usage of methods, receiver types, value and pointer receivers, and how methods can be defined on user-defined types.

Interfaces

The Interfaces section delves into interfaces in Go. It explains how interfaces are defined, implemented, and used in Go programs. It covers interface composition, type assertions, and the empty interface.

Interface Generics

The Interface Generics section discusses the addition of generics to interfaces in Go. It covers the use of type parameters and type constraints in generic interfaces, enabling code reuse and flexibility.