Pointers:
Pointers
suggest changeA pointer to a variable is an address in memory of that variable.
Go doesn’t allow pointer arithmetic. You can’t add to or subtract from pointers.
Zero value of a pointer is nil.
Basics of pointers:
v := 5
// pv is a pointer to v
pv := &v
fmt.Printf("v: %d, pv: %p\n", v, pv)
// we change the value of v via pv
*pv = 4
fmt.Printf("v: %d\n", v)
// two pointers to the same value have the same address
pv2 := &v
fmt.Printf("pv: %p, pv2: %p\n", pv, pv2)
v: 5, pv: 0xc00007c010
v: 4
pv: 0xc00007c010, pv2: 0xc00007c010
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents
4
Strings
5
Pointers
6
Arrays
7
Slices
8
Maps
9
Structs
10
Interfaces
15
Functions
16
Methods
18
Defer
20
Concurrency
22
Mutex
23
Packages
27
Logging
30
JSON
31
XML
32
CSV
33
YAML
34
SQL
35
HTTP Client
36
HTTP Server
38
Reflection
39
Context
40
Package fmt
41
OS Signals
42
Testing
49
gob
50
Plugin
53
Console I/O
54
Cryptography
59
Contributors