
في هذا الفيديو، سنقدم لغة البرمجة Go. ستتعرف عني، وما هو Go، وتاريخه، ولماذا يجب أن تتعلمه، وما يمكنك فعله باستخدام Go. سنتحدث أيضًا عن الأشخاص الذين أنشأوا Go. بنهاية هذا الفيديو، ستعرف سبب كون Go لغة رائعة للتعلم وكيف يمكن أن تساعدك في رحلتك البرمجية.
In this video, we’ll introduce the Go programming language. You’ll learn about me, what Go is, its history, why you should learn it, and what you can do with Go. We’ll also talk about the people who created Go . By the end of this video, you’ll know why Go is a great language to learn and how it can help you in your programming journey.
في هذا الفيديو، نستعرض خصائص لغة البرمجة Go، حيث ستتعرف على بساطتها وتعدد استخداماتها ودعمها لكل من البرمجة الموجهة للكائنات والبرمجة الوظيفية. سنناقش أيضًا إدارة الذاكرة التلقائية (جمع البيانات المهملة)، التجميع السريع، والتزامن المدمج، والمكتبة القياسية القوية، وإمكانات الأنظمة المشتركة. بنهاية الفيديو، ستفهم لماذا تُعتبر Go لغة قوية ومرنة تناسب مجموعة واسعة من مهام البرمجة.
In this video, we explore the characteristics of the Go programming language. You’ll learn about Go’s simplicity, versatility, and how it supports both object-oriented and functional programming. We’ll also discuss Go’s automatic memory management (garbage collection), fast compilation, built-in concurrency, strong standard library, and cross-platform capabilities. By the end of this video, you’ll understand why Go is a powerful and flexible language suitable for a wide range of programming tasks.
Important great note : " The old version of Go are fine the with new versions , which means there will be no conflicts (Backward compatible ) "
In this video, we guide you through downloading and installing Go on Windows, macOS, and Linux. We also show you how to set up Visual Studio Code to write and run your Go programs. By the end of this video, you’ll have a working Go environment and be ready to start coding your first Go programs
We will dive into the hierarchy of a Go project, covering packages, modules, and workspaces. By the end of this video, you’ll have a clear understanding of how to set up and organize your Go projects
Notes :
Workspaces are optionals and were introduced in go 1.18
Here you will make your first module in go and build your first program
Those are some rules of go lang :
1- Blocks of code in {}
2- No freedom in styling
3- Semicolon is optional
4- case sensitive Ahmed ahmed
5- strongly typed
6- Not oop , no classes or exceptions
In this video we understood the difference between constant and Variables in programming
You will understand what is a comment and why do we use it , and when do we use it .
In this video, we’ll explore variables and constants in Go. You’ll learn what variables are, how to declare and initialize them, and understand their scope. We’ll also introduce constants, explaining what they are and how they differ from variables. By the end of this video, you’ll be able to use variables and constants effectively in your Go programs
int- stores integers (whole numbers), such as 123 or -123
float32- stores floating point numbers, with decimals, such as 19.99 or -19.99
string - stores text, such as "Hello World". String values are surrounded by double quotes
bool- stores values with two states: true or false
A variable name must start with a letter or an underscore character (_)
A variable name cannot start with a digit
A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )
Variable names are case-sensitive (age, Age and AGE are three different variables)
There is no limit on the length of the variable name
A variable name cannot contain spaces
The variable name cannot be any Go keywords
Important note : " how to know if something is public or private ? like a function ,
if it starts with a capital letter it's public which you can use it anywhere
if it's not , then it's private "
To recap, packages in Go help organize and modularize your code. We learned about importing standard packages, the difference between public and private functions, and how to create and use custom packages. Keep exploring and practicing to become proficient with Go packages. Thanks for watching!
Also it can be inferred , you can write as many as you want and then it will decide the length of it .
var array_name = [...]datatype{values} // here length is inferred
To recap, slices in Go are dynamic and flexible, providing more functionality than arrays. We’ve covered how to declare and initialize slices, access and modify their elements, append new elements, understand their length and capacity, and create slices from arrays. Keep practicing with slices to get comfortable with their powerful features. Thanks for watching!
To recap, maps in Go are versatile and powerful data structures that store key-value pairs. We’ve covered how to declare and initialize maps, access and modify their elements, delete elements, check for key existence, and get the map length. Keep practicing with maps to get comfortable with their features. Thanks for watching!
this character is called " | " pipe , you maybe seen it command line before
To recap, the fmt package in Go provides a wide range of functions for formatted I/O operations. We’ve covered the basic functions, formatting verbs, and user input. Keep practicing using the fmt package to become more comfortable with its features. Thanks for watching!
package main
import "fmt"
// fmt package functions
/*
input and outputs
*/
func main() {
a := 10 // int
b := 13.34343434343 //float
fmt.Printf("Integer : %d\n",a)
fmt.Printf("Float %.2f\n",b)
var name string
fmt.Scanln(&name)
fmt.Println(name)
}
To recap, if statements are a powerful tool for making decisions in your code. We’ve covered the basic syntax, how to use if statements, common use cases, and best practices. Keep practicing writing if statements to get comfortable with their use. Thanks for watching!
To recap, nested if statements allow you to check multiple conditions in a hierarchical manner. We’ve covered the basic syntax, examples of using nested if statements, real-world scenarios, and best practices. Keep practicing writing nested if statements to get comfortable with their use. Thanks for watching!
package main
import "fmt"
// Calculator project using switch case
/*
hint:
fmt - > scanf , print
3 inputs : operator , 2 numbers
*/
func main() {
var operator string
var num1 , num2 float64
fmt.Println("Welcome to my Calculator ")
fmt.Println("Enter first number ")
fmt.Scanln(&num1)
fmt.Println("Enter The operator from ( + , - , / , * ) ")
fmt.Scanln(&operator)
fmt.Println("Enter second number ")
fmt.Scanln(&num2)
switch operator {
case "+" :
fmt.Printf(" The sum of the numbers = %.2f", num1 + num2 )
case "-" :
fmt.Printf(" The subtract of the numbers = %.2f", num1 - num2 )
case "/" :
fmt.Printf(" The division of the numbers = %.2f", num1 / num2 )
case "*" :
fmt.Printf(" The multiply of the numbers = %.2f", num1 * num2 )
default:
fmt.Println("Invalid operator")
}
}
To recap, loops are essential for repeating a block of code multiple times. The for loop in Go can be used in various forms, including basic, condition-only, and infinite loops. Loop control statements like break and continue help manage the flow of loops. Keep practicing writing loops to become more comfortable with their use. Thanks for watching!
To recap, functions are essential for organizing and reusing code in Go. We’ve covered the basics of function declarations and naming conventions. Keep practicing writing function declarations to become more comfortable with their use. Thanks for watching
To recap, parameters and arguments are essential for making functions more dynamic and reusable in Go. We’ve covered the basics of declaring parameters, passing arguments, using multiple parameters, and different parameter types. Keep practicing writing functions with parameters and arguments to become more comfortable with their use. Thanks for watching
To recap, return values are essential for passing results from a function back to the caller. We’ve covered the basics of returning single and multiple values, as well as using named return values in Go. Keep practicing writing functions with return values to become more comfortable with their use. Thanks for watching!
To recap, recursion is a powerful technique where a function calls itself to solve a problem. We’ve covered the basics of recursion, the structure of a recursive function, the importance of base and recursive cases, and some examples like factorial and Fibonacci. Keep practicing writing recursive functions to become more comfortable with their use. Thanks for watching!
Fibonacci task :
func fibonacci(n int) int {
if n <= 1 {
return n
}
return fibonacci(n-1) + fibonacci(n-2)
}
func main() {
fmt.Println("Fibonacci of 6:", fibonacci(6))
}
Explanation:
• func fibonacci(n int) int: Declares a recursive function named fibonacci that takes an integer n and returns an integer.
• if n <= 1 { return n }: The base case, returning n when n is 0 or 1.
• return fibonacci(n-1) + fibonacci(n-2): The recursive case, summing the results of fibonacci(n-1) and fibonacci(n-2).
To recap, pointers are variables that store the memory address of another variable, allowing for direct manipulation of data. We’ve covered the basics of declaring and using pointers in Go, and looked at an example demonstrating how pointers interact with variables. Keep practicing using pointers to become more comfortable with their use. Thanks for watching!
To recap, using pointers with functions allows you to modify the original values of variables directly, leading to more efficient and flexible code. We’ve covered how to pass pointers to functions and seen examples of modifying values through pointers. Keep practicing using pointers with functions to become more comfortable with their use. Thanks for watching!
package main
import "fmt"
// Task 1: Basic Pointer Declaration and Usage
func task1() {
var num int = 100
var ptr *int = &num
fmt.Println("Task 1:")
fmt.Println("Value of num:", num)
fmt.Println("Pointer ptr points to:", ptr)
fmt.Println("Value at ptr:", *ptr)
fmt.Println()
}
// Task 2: Modify Variable Value Using Pointer
func task2() {
var num float64 = 10.5
var ptr *float64 = &num
*ptr = 20.5
fmt.Println("Task 2:")
fmt.Println("New value of num:", num)
fmt.Println()
}
// Task 3: Passing Pointers to Functions
func doubleValue(ptr *int) {
*ptr = *ptr * 2
}
func task3() {
var num int = 10
fmt.Println("Task 3:")
fmt.Println("Before:", num)
doubleValue(&num)
fmt.Println("After:", num)
fmt.Println()
}
// Task 4: Swap Values Using Pointers
func swap(a *int, b *int) {
temp := *a
*a = *b
*b = temp
}
func task4() {
x := 5
y := 10
fmt.Println("Task 4:")
fmt.Println("Before swap - x:", x, "y:", y)
swap(&x, &y)
fmt.Println("After swap - x:", x, "y:", y)
fmt.Println()
}
// Task 5: Pointer to Pointer
func task5() {
var num int = 50
var ptr *int = &num
var pptr **int = &ptr
fmt.Println("Task 5:")
fmt.Println("Value of num:", num)
fmt.Println("Value at ptr:", *ptr)
fmt.Println("Value at pptr:", **pptr)
fmt.Println()
}
func main() {
task1()
task2()
task3()
task4()
task5()
}
Discover what structs are and why they are essential in Go programming. Learn how structs help you group related data and manage it more efficiently within your applications
Learn the syntax for defining structs in Go. Understand the basic structure of a struct and how to create your own custom data types using structs.
Understand how to access and modify the fields of a struct. This section provides examples that demonstrate how to interact with the data stored within a struct.
Learn how to create and use nested structs, where one struct contains another. This section illustrates the concept of composition and how it can be used to build complex data structures.
Nested structs are particularly useful in applications that require hierarchical data representation, such as user profiles with address details, order systems with nested product details, etc.
Struct methods are useful for encapsulating behaviors related to data structures. For example, you could have methods for performing operations on a User struct, like validating user input, updating user information, etc.
Learn how to compare structs and understand the rules for assignment and copying of struct instances. This section covers the nuances of struct equality and deep copying
1. Create a Struct and Initialize It:
• Define a Book struct with fields for Title, Author, and YearPublished.
• Write a constructor function to initialize a Book.
• Print the details of a Book instance.
2. Embed Structs:
• Create an Address struct with fields for Street, City, and PostalCode.
• Create an Employee struct that embeds Address and adds fields for Name and Position.
• Initialize and print the details of an Employee instance.
3. Compare Structs:
• Define a Car struct with fields for Make, Model, and Year.
• Create two instances of Car with the same values.
• Compare the two instances for equality and print the result.
4. Use Struct Methods:
• Define a Rectangle struct with fields for Width and Height.
• Write a method that calculates and returns the area of the rectangle.
• Create an instance of Rectangle, call the method, and print the area.
To recap, error handling is essential for writing robust programs. In Go, errors are handled using the built-in error type, and functions that can fail often return an error value. We’ve covered basic error handling, creating custom errors, and returning errors from functions. Keep practicing error handling in different scenarios to become more comfortable with it. Thanks for watching!
مرحبًا بكم في دورة البرمجة بلغة Go (GoLang) باللغة العربية! هذه الدورة الشاملة تهدف إلى إرشادك من المستوى المبتدئ وصولًا إلى المستوى المتقدم في البرمجة باستخدام لغة Go، وهي لغة برمجة مفتوحة المصدر طورتها شركة Google. تعتبر لغة Go من اللغات المميزة في عالم البرمجة بفضل بساطتها وكفاءتها وقدرتها العالية على التعامل مع العمليات المتزامنة.
ماذا ستتعلم في هذه الدورة؟
مبادئ البرمجة بلغة Go:
سنتعرف على أساسيات لغة Go من خلال شرح بسيط وواضح لأهم المفاهيم الأساسية مثل المتغيرات والثوابت، وكيفية التحكم في تدفق البرنامج باستخدام العبارات الشرطية والحلقات التكرارية.
مشاريع تطبيقية حقيقية:
سنقوم بتطبيق ما تعلمناه من خلال إنشاء مشاريع حقيقية مثل بناء واجهات برمجية (APIs) واستخدام لغة Go في تطوير تطبيقات عالية الأداء. ستساعدك هذه المشاريع على تعزيز مهاراتك البرمجية وتجهيزك للعمل في المشاريع الفعلية.
التعمق في المواضيع المتقدمة:
سنتناول مواضيع متقدمة في Go مثل التعامل مع الأخطاء (Error Handling)، والعمل مع الهياكل البيانية (Structs)، وتنفيذ العمليات المتزامنة (Concurrency). ستتعلم كيفية بناء تطبيقات قوية وفعالة باستخدام هذه الميزات.
أفضل ممارسات البرمجة بلغة Go:
سنتعلم كيفية كتابة كود نظيف وفعال، وكيفية تحسين الأداء باستخدام المؤشرات (Pointers) والوظائف (Functions)، وذلك لضمان كتابة برامج Go عالية الكفاءة.
من يستفيد من هذه الدورة؟
هذه الدورة مثالية للمبتدئين الذين يرغبون في بدء رحلتهم في تعلم البرمجة باستخدام لغة Go، وكذلك للمبرمجين ذوي الخبرة الذين يرغبون في إضافة لغة Go إلى مجموعة مهاراتهم. كما أنها مفيدة لمهندسي البرمجيات الذين يسعون لتعميق معرفتهم بلغة Go وتطبيقها في مشاريعهم اليومية.