2. References
var p *int
fmt.Printf("value of p: %v\n", p)
// value of p: <nil>myString := "hello" // myString is just a string
myStringPtr := &myString // myStringPtr is a pointer to myString's address
fmt.Printf("value of myStringPtr: %v\n", myStringPtr)
// value of myStringPtr: 0x140c050Creating a Pointer
Method 1: Nil Pointer (Empty)
Method 2: Get Address with &
&The & Operator: "Address Of"
& Operator: "Address Of"The * Operator: Two Uses
* Operator: Two UsesUse 1: Declare a Pointer Type
Use 2: Dereference (Get the Value)
Dereference
Complete Example
Visual Representation
Why Use Pointers?
Reason 1: Modify Variables in Functions
Reason 2: Efficiency with Large Data
Key Syntax Summary
Symbol
Meaning
Example
Common Pattern
What "No Pointer Arithmetic" Means
Practice Understanding
Assignment
Word
Replacement
Solution
Dynamic Solution
Dynamic Replacement (Count the Letters)
How strings.Repeat Works
strings.Repeat Works