Загрузка...

Pointers (Memory Addresses & Dereferencing) - Go Tutorial for Beginners #14

Master pointers in Go - understand memory addresses and direct value manipulation!

In this lesson, you will learn:
✓ What pointers are and why they matter
✓ Address-of operator (&)
✓ Dereference operator (*)
✓ Modifying values through pointers
✓ Pass by value vs pass by pointer
✓ Nil pointers and safety checks
✓ The new() function
✓ Why Go has no pointer arithmetic

⏱️ Timestamps:
0:00 - Introduction
0:27 - Pointer Basics (& and *)
2:25 - Modifying Values via Pointers
4:18 - Pointers in Functions
6:44 - Nil Pointers & Safety
9:10 - Recap
9:40 - End

💻 Source Code: https://github.com/GoCelesteAI/go_pointers

📝 Code Highlights:

// Address-of and dereference
x := 42
p := &x // p holds address of x
fmt.Println(*p) // dereference: prints 42

// Modify via pointer
*p = 100 // x is now 100

// Pass by value - doesn't modify original
func doubleValue(n int) {
n = n * 2 // only changes the copy
}

// Pass by pointer - modifies original
func doublePointer(n *int) {
*n = *n * 2 // changes the original
}

num := 10
doublePointer(&num) // num is now 20

// Nil safety
var p *int // p is nil
if p != nil {
fmt.Println(*p) // safe to dereference
}

📺 Full Playlist: Go Tutorial for Beginners
📺 Previous: Lesson 13 - Anonymous Functions & Closures
📺 Next: Lesson 15 - Structs

👍 Like and Subscribe for more Go tutorials!

#Go #Golang #Programming #Tutorial #Pointers #Memory #LearnToCode

Видео Pointers (Memory Addresses & Dereferencing) - Go Tutorial for Beginners #14 канала Codegiz — Built by Claude AI
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять